Created
September 23, 2016 21:28
-
-
Save blakewrege/1af915e7d52373670dd73c245d7d4e7b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private static void WebRequest( string serverAddress, string Nick, string Pass) | |
{ | |
string WEBSERVICE_URL = serverAddress; | |
try | |
{ | |
var webRequest = System.Net.WebRequest.Create(WEBSERVICE_URL); | |
if (webRequest != null) | |
{ | |
webRequest.Method = "GET"; | |
webRequest.Timeout = 1200; | |
webRequest.ContentType = "application/json"; | |
webRequest.Headers.Add("User", Nick); | |
webRequest.Headers.Add("Pass", Pass); | |
using (Stream s = webRequest.GetResponse().GetResponseStream()) | |
{ | |
using (System.IO.StreamReader sr = new System.IO.StreamReader(s)) | |
{ | |
var jsonResponse = sr.ReadToEnd(); | |
Console.WriteLine(String.Format("Response: {0}", jsonResponse)); | |
} | |
} | |
} | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.ToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment