How to call a RESTful API with ASP.NET 5

Richard.Davenport picture Richard.Davenport · Oct 1, 2015 · Viewed 13.9k times · Source

Working with ASP.NET 5 on my Mac in Visual Studio Code. I have a RESTful API I need to call and not sure exactly how to do it. I've seen many examples using WebClient, HttpClient, WebRequest and HttpWebRequest.

I think my pain point is the dnxcore50 framework. Can someone please point me in the right direction with some code samples?

Answer

Triet Doan picture Triet Doan · Oct 2, 2015

Here is an example about how to call a service. Please check the References and using carefully.

One important thing you have to do is install the Web API Client Libraries package: From the Tools menu, select NuGet Package Manager, then select Package Manager Console. In the Package Manager Console window, type the following command: Install-Package Microsoft.AspNet.WebApi.Client.

For the full source code, check this link.

Call service