Created
November 28, 2016 15:47
-
-
Save Msirkovsky/e7e3f73e53fe35dd6538e0f2ca1a9e4f to your computer and use it in GitHub Desktop.
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
private string PostRaw(string url, string data) | |
{ | |
var request = (HttpWebRequest)WebRequest.Create(url); | |
request.ContentType = "application/json"; | |
request.Method = "POST"; | |
using (var requestWriter = new StreamWriter(request.GetRequestStream())) | |
{ | |
requestWriter.Write(data); | |
} | |
var response = (HttpWebResponse)request.GetResponse(); | |
if (response == null) | |
throw new InvalidOperationException("GetResponse returns null"); | |
using (var sr = new StreamReader(response.GetResponseStream())) | |
{ | |
return sr.ReadToEnd(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment