Send Raw List of JSON in System.Net.Http in UWP C#

Viewed 64

How to send a list of Json without converting into JsonString in C# .NET. I'm using C# 10 with .NET5. I'm using System.Net.Http for sending post requests. Anyone please help me with this...

1 Answers

Send it as a plain System.String (string) using System.Net.Http.StringContent:

var json = "...";
var data = new System.Net.Http.StringContent(json, Encoding.UTF8, "application/json");

var url = "https://httpbin.org/post";
using var client = new System.Net.Http.HttpClient();

var response = await client.PostAsync("http://url.com", data);
Related