i found this post hope be useful for u
http://blog.flair-systems.com/2010/05/how-to-consume-rest-based-services.html
Q. How to consume REST based-services?
Assume we have REST based-service contains method Add which takes two operands op1 and op2 and return the summation.
A) Create any project type (Console, Windows or even Web-based application) and add the below lines :
Code Snippet
- using System.Net;
- using System.IO;
B) Write some code to consume the service:
Code Snippet
- string parameters;
- string response;
- // Create the request obj
- WebRequest request = WebRequest.Create("serviceURL/Add");
- // Set values for the request back
- request.Method = "POST"; //REST based-services using Post method
- request.ContentType = "application/json"; //tells request the content typs is JSON
- parameters = "{\"op1\":2,\"op2\":\"1\"}";
- request.ContentLength = parameters.Length;
- // Write the request
- StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
- requestWriter.Write(parameters);
- requestWriter.Close();
- // Do the request to get the response
- StreamReader responseReader = new StreamReader(request.GetResponse().GetResponseStream());
- response = responseReader.ReadToEnd();
- responseReader.Close();
Response value should be 3 if you implement Add method correctly :))