Use the HttpWebRequest class to request a web API. Below is a quick example for something that I used to query any other holiday service (this service only allowed POST / GET, not DELETE / PUT).
HttpWebRequest request = WebRequest.Create(actionUrl) as HttpWebRequest;
request.ContentType = "application/json";
if (postData.Length > 0)
{
request.Method = "POST";
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(postData);
writer.Close();
}
}
else
{
request.Method = "GET";
request.ContentLength = 0;
}
string responseData = string.Empty;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
responseData = reader.ReadToEnd();
reader.Close();
}
response.Close();
}
return responseData;
nuget, " Microsoft ASP.NET Web API", WebAPI. (http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client)