Code: Select all
using (HttpClient httpClient = new HttpClient())
{
using (HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("POST"), url))
{
string content = "{ \"exampleJson\": \"This is an example\" }";
request.Content = new StringContent(content);
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
HttpResponseMessage httpResponse = await httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead);
httpResponse.EnsureSuccessStatusCode();
// But what do I do to get the json data as it is coming in from the web?
return;
}
}