Here\'s the code I\'m using:
// create a request
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(url); request.KeepAlive = false;
request.Protoco
I find this to be the friendliest and most concise way to post an read JSON data:
var url = @"http://www.myapi.com/";
var request = new Request { Greeting = "Hello world!" };
var json = JsonSerializer.Serialize(request);
using (WebClient client = new WebClient())
{
var jsonResponse = client.UploadString(url, json);
var response = JsonSerializer.Deserialize(jsonResponse);
}
I'm using Microsoft's System.Text.Json
for serializing and deserializing JSON. See NuGet.