Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a rest API, returns JSON response.
I have to call this rest API from web application.

it's quite easy to develop
But, I want the simplest way to call this rest url.

Url :

Method: GET

example URL :

What I have tried:

string reqUrl = string.Format("billing/customerDetails/{0}/billarrangement/{1}/bill/{2}getbillSummary?uan={3}", cID, aNo, bId, UAN);

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET";
req.Credentials = CredentialCache.DefaultCredentials;
req.Accept = "text/json";

using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
      if (resp.StatusCode == HttpStatusCode.OK)
        // my code

I want to know if this one is simplest.
Or if anything wrong, please correct me.
If its not simplest, please help me with that.
Updated 16-Oct-17 22:25pm
Richard MacCutchan 17-Oct-17 4:20am    
What happens when you try it?
Kingshuk_SP 17-Oct-17 5:12am    
Richard, its well executing. but I was asking if any simpler way is there. :)

1 solution

There's nothing wrong with your code if you want to keep it. There are some third-party libraries you could look at that might make things a little simpler.

RestSharp - Simple REST and HTTP Client for .NET[^]
Share this answer
Wessel Beulink 17-Oct-17 4:27am    
I would agree to use RestSharp. It's a good library to use!
Kingshuk_SP 3-Jan-19 16:04pm    
ok noted. thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900