public HttpWebRequest GenerateHttpWebRequest_post(string uriString, string postData, string contentType)
{
Uri uri = new Uri(uriString);
httpRequest = (HttpWebRequest)WebRequest.Create(uri);
byte[] bytes = Encoding.UTF8.GetBytes(postData);
httpRequest.ContentType = contentType;
httpRequest.Method = "POST";
httpRequest.ContentLength = postData.Length;
using (Stream requestStream = httpRequest.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
return httpRequest;
}
|