Hi All,
I am getting the following error when I try to process the response of a REST API
Failed to parse response of REST API
Parsing '': Unexpected character encountered while parsing value: E. Path '', line 0, position 0.
I am getting this error once in a day not everytime. The REST API I am using gives a JSON response and I am just processing it.
What is the reason for this error and how can I eradicate it?
Ananth wrote:
Your JSON might be Invalid.Please check the response json through LOG.
We often get this kind of error when the response json is not according to the structure that we take. Or it might be invalid as asif told. Check the response of that json.
Sachin
Sachin Mahawar wrote:
Hi Sachin,
If the Json response is invalid, I should get the error everytime when I am requesting the REST API. But I am not getting the error all the time.
Then I would recommend you to put a log and analyse both the json wrong vs correct one.
Hello Ananth,
Usually this error happens when the answer is not a valid JSON (like no JSON at all, due invalid authorization or just because the server did not find anything). This can happen for many number of reasons, so it's possible to happen even if most of the time the server still returns a valid response.
Without knowing the specification of the web service you're consuming is hard to tell anything, but you can take a look here:
https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/REST/Troubleshoot_a_REST_API
And also here:
https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/REST/Consume_REST_APIs/Handling_REST_Errors
This should give you an idea on how to handle errors returned by the web service being consumed and also how to increase the logging level so that you can take a look in the answer you are receiving, so that you can understand what is going on.
Cheers.
I'm going to plug my old short post about setting the log level of a REST API.
As for why only sometimes this happens, I've seen REST implementations that return text/plain instead of text/json with a plain text error message in case of wrong data or some other problem. So it needn't be the case that it would always fail.
Hi Ananth ,
Try to run the API first by any API testing tool like Postman and see what response you are getting back from API.
Also you can copy and paste the API response from postman in any JSON format tool to check what exactly causing issue.
Also while consuming JSON API you can add OnResponse method to debug more.
Regards
-PJ-
Hello @Eduardo Jauch @Kilian Hekhuis & @Pramod Jain
I am same issue while consuming 3rd party REST API
Kindly find the below response from the api
{ "messages": { "result": "Ok", "message": [ { "code": "P001", "text": "Successful." } ] }}
It is perfectly fine with the POSTMAN and Fidler i did the test only having issue with outsystems.I am getting the below error
This is my structure
Please share your thoughts on it, so that i can resolve it
Having same error message in the service center. Where I set logging level to full
Hi Pradip,
This looks like a REST service that returns a UTF BOM (byte order mark) at the start of the message. I've encountered this once, and had to strip it from the message in an On After Response.
Can you please help me how can i do it? I have more than one request & for every request something differente/ dynamic is coming. For 3 diff. request have 3 diff. o/p with some extra charactes or special characters.Is there any std way to normalize it. Even if i created structure using json it is not supporting because in the normal string that extra space or character is not visible.
If you help to resolve it, will be helpful.
I'll answer in your question here.