Guest User

Untitled

a guest
Dec 13th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. WebRequest req = WebRequest.Create(@"https://api.tookanapp.com");
  2.  
  3. req.Method = "GET";
  4.  
  5. HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
  6. if (resp.StatusCode == HttpStatusCode.OK)
  7. {
  8. using (Stream respStream = resp.GetResponseStream())
  9. {
  10. StreamReader reader = new StreamReader(respStream, Encoding.UTF8);
  11. Console.WriteLine(reader.ReadToEnd());
  12. }
  13. }
  14. else
  15. {
  16. Console.WriteLine(string.Format("Status Code: {0}, Status Description: {1}", resp.StatusCode, resp.StatusDescription));
  17. }
  18. Console.Read();
Add Comment
Please, Sign In to add comment