Earn income with your C# skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

How to make an HTTP POST web request in C#

Use HttpClient class for issueing post web requests and other types of requests. It is a newer API for working with HTTP and is designed to work well with web APIs, REST-based services, and custom authentication schemes. In .NET Framework, HttpClient relied on WebRequest and WebResponse, but starting with .NET Core 3, it handles HTTP itself.

Below is the code for making a post request.


using System.Net.Http;

private static readonly HttpClient client = new();

var values = new Dictionary<string, string>
{
   { "thing1", "hello" },
   { "thing2", "world" }
};

var content = new FormUrlEncodedContent(values);

var response = await client.PostAsync(
       "http://www.example.com/postable.aspx", content);

var result = await response.Content.ReadAsStringAsync();



Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0