REST (Representational state transfer) is very popular architecture to transfer resource on web. Using
HTTP methods (GET, PUT, POST, DELETE),the
Internet media type of the data supported by the web service(JSON, XML or YAM etc.) and principles of REST we can build RESTful web service.
Today many service provided as restful web service which can easily accessed by any browser on any system with any language.
I would like to give you Example with code here to make post call using json data in asp.net.
we need to add below namespcae for that
- using System.Net;
- using System.IO;
WebResponse: Responsible to provide response from URI
WebRequest: Responsible to make request to URI
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLn3ftlwuqS8rOIdATF0LCq1vc4n1qMYszWqqwVGYbbLdDUuIZ3Vt6E5HdaZgReAht1aKB5xD_mXg4v4pm-tj3FQcAUg_nS6XL2XW2hKNEVKBoBzWN-Qm3ORPZ2g4dU3joToP472aqLjVX/?imgmax=800)
In above code i made request with basic authentication (In my words: if you'll request service URI with browser and if it will prompt with login box then that service requires basic authentication to access resources ) and try to get response.
you can test your rest call using Fiddler as well before implementation of code to test that web service working is as per expectation.
Important Note :
As per stackoverflow's answer take care about this header Expect: 100-Continue.
"By default, .NET will tag outgoing POST requests with the header Expect: 100-Continue. If the server doesn't support this, it will fail with a 417 error.
To get .NET to not do this, execute the following before creating your WebRequest object:
System.Net.ServicePointManager.Expect100Continue = false;
"
Hope it will be helpful to you!