Skip to content

Instantly share code, notes, and snippets.

@deepumi
Last active December 22, 2016 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepumi/760aafa6705edbada21109cb2c0d1762 to your computer and use it in GitHub Desktop.
Save deepumi/760aafa6705edbada21109cb2c0d1762 to your computer and use it in GitHub Desktop.
HttpRequest Sample
try
{
var httpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("API URL HERE");
httpWebRequest.Headers.Add("Authorization", string.Format("Bearer {0}", "REPLACE YOUR TOKEN"));
httpWebRequest.ContentType = "application/json"; //for xml response change to application/xml
httpWebRequest.Method = "GET";
httpWebRequest.Accept = "application/json";
var httpResponse = (System.Net.HttpWebResponse)httpWebRequest.GetResponse();
using (var reader = new System.IO.StreamReader(httpResponse.GetResponseStream()))
{
var result = reader.ReadToEnd(); //json response
}
}
catch
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment