JSON REST API Call in POST CALL returns 400 with module

Hi,

i have created module to send JSON REST POST request in my custom app but it always return 400. Suggesting that data are wrongly propagated i have only one bundle.

[
{
“mode”: “High”,
“tone”: “Casual”,
“prompt”: “this is robot text”,
“business”: false,
“rephrase”: true
}
]

and module contains following settings

“method”: “POST”,
“headers”: {
“api-token”: “{{connection.apiKey}}”,
“Content-Type”: “application/json”
},
“qs”: {},
“body”: {
“prompt”: “{{createJSON(parameters.prompt)}}”,
“rephrase”: “{{parameters.rephrase}}”,
“tone”: “{{createJSON(parameters.tone)}}”,
“mode”: “{{createJSON(parameters.mode)}}”,
“business”: “{{parameters.business}}”
},
“response”: {
“output”: “{{parseJSON(body.result)}}”
}

any suggestion?

The prompt creating json is odd. Are you having AI format the JSON body for the request? I suggest swapping your destination URL for something like a test URL (hookrelay, etc) to see what is actually being sent.

1 Like

In the custom functions, the JSON.stringify() or JSON.parse() functions should be used instead of createJSON() or parseJSON() .