API REST POST Request body in JSON is treated as string

I've been trying to setup a POST request in my REST API; however I'm having an issue with the body I send on the request; the body contains a nested object, but the payload is always sent as a string; I've followed the steps mentioned in this article:

Perform REST API requests

But the same thing happens, no matter how I choose to format the object it is always sent as an escaped string, which prevents my API to actually recognize the body and just returns an empty message.


I need the payload to be an actual JSON, any ideas?


Are you able to build your object using the Raw type with a JSON.parse()?

{{JSON.parse('{"method": "", "params": {"key1": "", "key2": ""} }')}}


It seems like the Object output is the same in both our setups. Does the body still send as a text type even when using the JSON object key/value setup? Also, for this resource, are there any other headers that might be overriding the headers you are supplying?

Hey! I just tried your suggestion with JSON.parse() but I still get the same result, when I check the body in the Request tab it shows up as a string.

Looking like this

    "body": "{\"method\":\"abc\",\"params\":{\"key1\":\"abc\",\"key2\":\"abcdef\"}}",

I have also tried using the key/value pair setup and the result is the same

Hi @ivanbaubap @pyrrho

I'm having the same issue trying to pass a JSON object to the Jira ID (for filtering Issues based on a project and filter. This is my Body:

  "jql": "project = INTSD and filter = 17653"

I've tried constructing the string in a Component, using a Raw body, JSON Key:Values but I always see the request body adding the escape characters, same as you it seems. For example:

 "body": "{\"jql\": \"project = INTSD and filter = 17653\"}"

Attempted using JSON.parse just now, but same result.

The same request works fine in Postman.

Love to know if you find a solution!


1 Like

Hello @ivanbaubap and @nickaus !

Do you have access to the API to see what it is receiving?

I tested out the same payload using an API I spun up in Pipedream to generate an endpoint, and the body of the request was coming in as JSON even though in Retool the Query Output will always show the body as a string with a ton of '' in it.

Also have you tried clicking on the dropdown under "Body" to the query to switch from Raw to JSON? If your API is giving back an error message if you could share that it would be helpful to debug.

I tried {"method": "", "params": {"key1": "", "key2": ""} } under RAW and it showed that my API I spun up in Pipedream was receiving JSON as the body.