JSON Decoder : Unexpected character encountered while parsing value
After fixing an error with JSON decoder -Property not specified in JSON decoder, got one more error from JSON decoder-

From the error it is clear that the data in response from the api is not valid JSON, thus the decoder throws error.
I went through the 07acked service instance and checked what exactly is received, and as can be seen in below snap - it was HTML and no JSON message.

And as the returned message starts with < , the decoder was not able to parse it as valid JSON message is like:
{
"company": "Maruti",
"name": "Swift",
"price": 800000
}
Note: The RestApi has not implemented the required functionality, only instance of webapi is provisioned in Azure - thus the HTML is returned.
Here, we can't do anything except get the functionality implemented in Rest Api and let it return valid message. This error can also be encountered in case you are using JSON decoder and you receive XML.
From the error it is clear that the data in response from the api is not valid JSON, thus the decoder throws error.
Why it happened
I went through the 07acked service instance and checked what exactly is received, and as can be seen in below snap - it was HTML and no JSON message.
And as the returned message starts with < , the decoder was not able to parse it as valid JSON message is like:
{
"company": "Maruti",
"name": "Swift",
"price": 800000
}
Note: The RestApi has not implemented the required functionality, only instance of webapi is provisioned in Azure - thus the HTML is returned.
What to do
Here, we can't do anything except get the functionality implemented in Rest Api and let it return valid message. This error can also be encountered in case you are using JSON decoder and you receive XML.
Comments
Post a Comment