Last active
December 22, 2016 15:13
-
-
Save deepumi/760aafa6705edbada21109cb2c0d1762 to your computer and use it in GitHub Desktop.
HttpRequest Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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