You must Sign In to post a response.
  • Category: ASP.NET

    How to create Web API in .Net with Get Method using multiple parameter ?

    How to create Web API in .Net with Get Method using multiple parameter ?
  • #766810
    Hi,

    As per your post I came to know you want basic knowledge in Web API, I suggest you to go through the below links, those might be helpful to you.

    https://docs.asp.net/en/latest/tutorials/first-web-api.html
    http://www.codeproject.com/Articles/659131/Understanding-and-Implementing-ASPNET-WebAPI

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #766859
    Study the Webclient class which has namespace in System.Net.So you will get deep idea what is WebAPI.
    SRI RAMA PHANI BHUSHAN KAMBHAMPATI

  • #766951
    I am requesting a .php page and passing function as an argument which in php page

    string URI = @"http://XXX.XXX.XXX.XX/XXXXXX/index.php?fn=addSession";
    WebClient wc = new WebClient();
    wc.uploadvalues(URI,nam1);
    string URI = @"http://192.168.1.85/xxxx/index.php?fn=addSession";
    WebClient wc = new WebClient();
    NameValueCollection inputs = new NameValueCollection();
    inputs.Add("fn", "addSession");
    inputs.Add("id", sessionid);
    inputs.Add("step", stepid.ToString());
    inputs.Add("option", type);
    inputs.Add("date", datetimenow.ToString());
    inputs.Add("view", "0");
    inputs.Add("datefrom", fromdate.ToString());
    inputs.Add("dateto", todate);
    inputs.Add("numfrom", numfrom.ToString());
    inputs.Add("numto", numto.ToString());
    inputs.Add("word", EncryptionDecryption.Encrypt(keywords.ToString(), true));
    inputs.Add("phrase", EncryptionDecryption.Encrypt(phrases.ToString(), true));
    inputs.Add("other", otherfiledetails);


    byte[] retvalue = wc.UploadValues(URI, inputs);
    string value = ASCIIEncoding.ASCII.GetString(retvalue);





    it will invoke and return the value in string. So please go through the below url

    http://www.dotnetspider.com/resources/45805-How-to-upload-values-or-UploadData-to-Other-Webservice-Programing-languages.aspx

    SRI RAMA PHANI BHUSHAN KAMBHAMPATI

  • #766952
    I hope you know the concept of WEP API in .net. So I am not going to explain more about it. According me you can do this in two ways. You can add parameters in the WEP API method. So you can send the parameters as query string from the client call. The query string values will be the parameters
    For example if you are sending http:\\localhost\AppName\Webmethod?Name=test&Age=26

    In the above method Name and Age will be you parameters of your web API method.

    Then second ways is create class having multiple properties and do the post method and get the result.

    using (var Myclient = new HttpClient())
    {
    Myclient.BaseAddress = new Uri("http://localhost/AppName/");
    Myclient.DefaultRequestHeaders.Accept.Clear();
    Myclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    HttpResponseMessage Myresponse = await client.GetAsync("webapi/Items");
    if (Myresponse.IsSuccessStatusCode)
    {
    List MyItem = await response.Content.ReadAsAsync>List>();
    }
    }

    The above is the sample code for access the web api method with derived type

    By Nathan
    Direction is important than speed


  • Sign In to post your comments