ahmadnassri/httpsnippet

View on GitHub
src/targets/csharp/httpclient/fixtures/jsonObj-multiline.cs

Summary

Maintainability
A
2 hrs
Test Coverage
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri("http://mockbin.com/har"),
    Content = new StringContent("{\n  \"foo\": \"bar\"\n}")
    {
        Headers =
        {
            ContentType = new MediaTypeHeaderValue("application/json")
        }
    }
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}