Sending a POST request with a string payload using System.Net.HttpWebRequest

suggest change
string requestUri = "http://www.example.com";
string requestBodyString = "Request body string.";
string contentType = "text/plain";
string requestMethod = "POST";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri);
request.Method = requestMethod;
request.ContentType = contentType;

byte[] bytes = Encoding.UTF8.GetBytes(requestBodyString);
using (Stream stream = request.GetRequestStream())
{
    stream.Write(bytes, 0, bytes.Length);
}

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents