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

suggest change
string requestUri = "";
string requestBodyString = "Request body string.";
string contentType = "text/plain";
string requestMethod = "POST";

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

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

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Feedback about page:

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

Table Of Contents