You can use the PostAsJsonAsync method, which can be found in extension builds:
System.Net.Http.Formatting.dll
Example
public static async Task SendJsonDemo(object content) { using(var client = new HttpClient()) { var response = await client.PostAsJsonAsync("https://example.com", content); } }
If you want to add custom headers to the request, add it to DefaultRequestHeaders :
client.DefaultRequestHeaders.Add("mycustom", "header1");
source share