REST API payload in json treated as text

Hi All,

For some reasons, the output of my REST API (json) is treated as normal text (i.e. in is encapsulated in a JSON with a "message" attribute). When I test this same API in postman or curl, I get a proper JSON payload as expected. See screenshot below. Note: My API does return a property "Content-Type" = 'application/json'.

Thanks and regards
Bertrand


My guess is that Postman is handing that payload. It has been years since I have used Postman and I don't recall all of it's "features." I haven't seen Retool change the response data. It may be worth a try to see what the data looks like using cURL or Insomnia as reference.

You can work around this by writing transformer code on the query to grab the data and return it as regular JSON.

image

Hi,
I get the same problem and I confirm that Curl and Postman give the same result. So I imagine Retool is adding the message attribute. Will try now with the transformation.

Hey,
I did not post here but I figured what was happening on my side... just in case, someone else has a similar issue.
My API was developed in python. Some of the data I was returning were NaN (not a number) and my JSON conversion were just returning them as NaN (e.g. {"b": NaN}. NaN is obviously not a valid value in JSON; that's why retool was interpreting my API output as a text instead of treating it as a valid JSON. I replaced the NaN with null (e.g. {"b": null}; i.e. a valid JSON value) and the issue disappeared!
In a nutshell, not a retool issue but a stupid issue with my API (which I did not spot because Postman is more permissive with these types of issues)
Cheers