Last active
June 13, 2018 11:47
-
-
Save michaelbramwell/4729054 to your computer and use it in GitHub Desktop.
Http Request POST
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
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