views:

402

answers:

4

Hello, I have a REST webservice that I need to consume in C#. I need support for more than just GET requests though. I need everything that is done by REST including GET, PUT, POST, and DELETE. What is the best way of interfacing with this? I do not see anything for HTTPRequest to be able to do POST or anything other than GET unless you construct your own headers(which I prefer not to)

Is there some easy and lightweight way to fully consume REST webservices in C#?

+1  A: 

You could take a look at the REST Starter Kit on CodePlex.

Darin Dimitrov
+3  A: 

Check out the series of screencasts on WCF REST up on Channel 9:

http://channel9.msdn.com/tags/REST%20Starter%20Kit%20endpoint%20screencasts/

There's a great one amongst those called Consuming REST services with HttpClient which should give you a nice step-by-step instruction on how to do all of this.

Also check out the WCF REST Developer Center on MSDN for more articles, blog posts, and tutorial on WCF and REST.

marc_s
+1 for using the HttpClient. I also did some blog posts here on the subject http://www.bizcoder.com/index.php/2009/12/08/why-the-microsoft-http-library-is-awesome/
Darrel Miller
A: 

HTTPRequest is the request currently processed in a ASP app.

To make outboud HTTP REST requests, use the HttpWebRequest class. It has properties like Method (POST, PUT, DELETE) and you can write your payload into the request stream returned by GetRequestStream (or its async counterpart for high performance).

Remus Rusanu
+2  A: 

The HttpClient in the Microsoft.Http namespace that comes with the WCF Rest Starter kit is very helpful.

Aaron Skonnard from Pluralsight created several articles and screencasts highlighting the HttpClient.

There are several more resources that he posted to the Pluralsight blog in March 2009 covering the HttpClient.

Brad Mellen-Crandell