Skip to content

Instantly share code, notes, and snippets.

@michaelbramwell
Last active June 13, 2018 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michaelbramwell/4729054 to your computer and use it in GitHub Desktop.
Save michaelbramwell/4729054 to your computer and use it in GitHub Desktop.
Http Request POST
string getUrl = "http://whatevatreva.kwom";
string postData = String.Format("organization_id={0}&subscriber_firstname={1}", "313", "Treva");
HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(getUrl);
getRequest.Method = WebRequestMethods.Http.Post;
getRequest.ContentType = "application/x-www-form-urlencoded";
byte[] byteArray = Encoding.ASCII.GetBytes(postData);
getRequest.ContentLength = byteArray.Length;
Stream newStream = getRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
newStream.Close();
string result = string.Empty;
HttpWebResponse getResponse = (HttpWebResponse)getRequest.GetResponse();
using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))
{
result = sr.ReadToEnd();
}
Response.Write(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment