Skip to content

Instantly share code, notes, and snippets.

@sdqali
Created January 16, 2012 20:58
Show Gist options
  • Save sdqali/1623042 to your computer and use it in GitHub Desktop.
Save sdqali/1623042 to your computer and use it in GitHub Desktop.
var request = (HttpWebRequest) HttpWebRequest.Create("https://example.com/foo");
request.ServicePoint.Expect100Continue = false;
request.Credentials = new NetworkCredential("user", "password");
request.Method = "PUT";
request.ContentType = "application/x-www-form-urlencoded";
byte[] objByteArray = Encoding.UTF8.GetBytes("foo=bar");
request.ContentLength = objByteArray.Length;
var dataStream = request.GetRequestStream();
dataStream.Write(objByteArray, 0, objByteArray.Length);
dataStream.Close();
var response = request.GetResponse();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment