Reputation: 449
Can you recommend a library/simple approach to calling REST API services from ASP.NET MVC3. In Nuget I see things like RESTSharp, Hammock, Craig's Utility Library. I am looking for a common helper that I can then plug in multiple services.
Many thanks.
Upvotes: 1
Views: 799
Reputation: 6608
Starting a new MVC4 project comes with some default Microsoft WebApi packages for publishing and communicating with REST Apis - so if you have the opportunity to do this in MVC4 I would take it.
If not, you can still bring in the necessary nuget package into an MVC3 project to consume an api.
Install-Package Microsoft.Net.Http
The you can do things in your controller/domain layer like:
var client = new HttpClient();
var uri = "http://www.myapi.com";
var content = client.GetAsync(uri).Result.Content;
Upvotes: 4