Skip to content

Instantly share code, notes, and snippets.

@mikeminutillo
Created April 13, 2013 04:13
Show Gist options
  • Save mikeminutillo/5376901 to your computer and use it in GitHub Desktop.
Save mikeminutillo/5376901 to your computer and use it in GitHub Desktop.
WebAPI simple http client
var request = WebRequest.Create("http://localhost:63180/api/values") as HttpWebRequest;
request.Accept = "text/xml;text/json";
var response = request.GetResponse() as HttpWebResponse;
new { response.StatusCode, response.ContentType }.Dump("Details");
using(var stream = response.GetResponseStream())
using(var reader = new StreamReader(stream))
reader.ReadToEnd().Dump("Pay Load");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment