Consuming REST services using HttpClient

NOTE: This was cross posted from here .

If you have a need to consume REST Services from .NET Framework based code, then you should really have look at the WCF Rest Starter Kit.  There is a handy class called HttpClient that is, in my opinion, provides the best / cleanest way to consume REST services at the http level.  Essentially, it gives you the ability to make http calls as easy as:

image

There is so much more to HttpClient than the little snippet above, including ways to easily hydrate / deserialize the response of the REST service into a .NET types.  You have quite a bit of power / control over the common REST service consumption scenarios.  There’s a nice little blog post over at The .NET Endpoint blog which covers HttpClient.  The BEST starting point, again my opinion, for learning about HttpClient is these two Ch. 9 screencasts by Aaron Skonnard:

https://channel9.msdn.com/shows/Endpoint/endpointtv-Screencast-Consuming-REST-services-with-HttpClient/

https://channel9.msdn.com/shows/Endpoint/endpointtv-Screencast-Processing-Message-Content-using-HttpClient-class/

Once you’ve watched the screencasts and read the blog post, then you will probably want to learn a bit more about the WCF REST Starter Kit.  Here’s a great overview of the kit (also by Aaron Skonnard):

https://msdn.microsoft.com/en-us/library/ee391967.aspx

-Marc