-1

I run the following code in both .net 6.0 and 4.8:

    try
{
    var postData = new List<TireOrderData>
    {
        orderData
    };
    var json = JsonSerializer.Serialize(postData);
    StringContent stringcontent = new StringContent(json, Encoding.UTF8, "application/json");
    using (HttpResponseMessage response = await httpClient.PostAsync(
    "rest/settire", stringcontent
    ))
    {
        var message = await response.Content.ReadAsStringAsync();
        Console.WriteLine($"{message}\n");
    }
}
catch (Exception ex)
{
    Console.WriteLine(ex.ToString());
}

In .net 6.0 it always successfully calls the web service and return 200 OK response. However in .net 4.8 it returns 400 bad request with the following message:

{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-0880fdd46c1e1d2c7de15c6103cad81f-03c935a198e357f3-00","errors":{"$":["The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0."],"inputs":["The inputs field is required."]}}

Have someone experience like this?

Majid Majed
  • 326
  • 2
  • 12

0 Answers0