Skip to content

PostAsJsonAsync extension method sets Content-Length to 0 in .NET Core 2.1 with any versions of System.Net.Http and System.Net.Http.Formatting #252

Closed
@doboczyakos

Description

@doboczyakos
var response = await _client.PostAsJsonAsync(requestUri, value, cancellationToken);

Request object is null on the server side because content length is set to 0.
I've tried the newest versions of System.Net.Http and System.Net.Http.Formatting and the issue is the same.
It works if I replace this with the following:

var objectContent = new ObjectContent(value, new System.Net.Http.Formatting.JsonMediaTypeFormatter(), (System.Net.Http.Headers.MediaTypeHeaderValue)null);
await objectContent.ReadAsStringAsync();
var response = await _client.PostAsync(requestUri, objectContent, cancellationToken);

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions