Your issue is the string is not valid json. A json string has quotes around it. Ex
“Valid json string”
So your server is not returning json. The client code should check the content-type. It’s probably text, not json.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In my Blazor app, I am getting a response back from the API that consists of a single string value. I'm trying to deserialize using:
return await JsonSerializer.DeserializeAsync<T>(await response.Content.ReadAsStreamAsync(), options);
In the above case, T is string. This is producing a "System.Text.Json.JsonException: 'V' is an invalid start of a value" error (V is the first character of the string being returned from the API). Visually inspecting the response content in the debugger, it looks like a UTF-8 encoded string. Is there something I'm missing?
Thanks!
Dennis
Your issue is the string is not valid json. A json string has quotes around it. Ex
“Valid json string”
So your server is not returning json. The client code should check the content-type. It’s probably text, not json.