How to fix Unhandled exception rendering component: The JSON value could not be converted to System.Int32.

tony kong 0 Reputation points
2024-08-22T13:57:53.59+00:00

When I use the PlaceOrder method, it causes this error. The version is 8.0. Thank you.

async Task PlaceOrder()
    {
        isSubmitting = true;
        var response = await HttpClient.PostAsJsonAsync(NavigationManager.BaseUri + "orders", OrderState.Order);
        var newOrderId = await response.Content.ReadFromJsonAsync<int>();
        OrderState.ResetOrder();
        NavigationManager.NavigateTo("/");
    }
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,877 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,584 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 65,576 Reputation points
    2024-08-22T15:35:42.2666667+00:00

    The response body is probably not a valid numeric string. Post its value.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.