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

suggest change
string requestUri = "http://www.example.com";
string requestBodyString = "Request body string.";
string contentType = "text/plain";
string requestMethod = "POST";
    
byte[] responseBody;    
byte[] requestBodyBytes = Encoding.UTF8.GetBytes(requestBodyString);

using (var client = new WebClient())
{
    client.Headers[HttpRequestHeader.ContentType] = contentType;
    responseBody = client.UploadData(requestUri, requestMethod, requestBodyBytes);
}

Feedback about page:

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



Table Of Contents