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("/");
    }
Developer technologies | .NET | Blazor
Developer technologies | .NET | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,236 Reputation points Volunteer Moderator
    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.