I recieve error from outer api, I think there is something wrong with my generated json content because when I'm sending the same data from postman, I get correct response.
Is there a way to preview what json will be generated from JsonContent? I have a http client method:
public async Task<ResponseDto> UploadAsync(RequestDto model, CancellationToken cancellationToken)
{
var requestUri = HttpHelper.BuildUri(uri.UPLOAD);
JsonContent content = JsonContent.Create(model); //<= how read that JsonContent
/* there is not problems
var response = await _client.PostAsync(requestUri, content, cancellationToken);
string responseContent = await response.Content.ReadAsStringAsync(cancellationToken);
return JsonSerializer.Deserialize<ResponseDto>(responseContent)
?? throw new HttpRequestException(responseContent);*/
}
.SerializeToStreamto aMemoryStreamand then convert that to astring. Or use a tool like Telerik's Fiddler to capture the request. I looks like System.Text.Json is used internally, so perhaps try just serializing it with that to start with to see if anything obvious if wrong.StringContentto post it as explained here. P.S alternatively to Fiddler you could also use Wireshark since it's free.