Hi,
i've developed a module to send JSON REST POST requests within my custom application, but it consistently returns a 400 error. This suggests the data might be incorrectly formatted, as I'm only sending one bundle.
json
[
{
"mode": "High",
"tone": "Casual",
"prompt": "this is robot text",
"business": false,
"rephrase": true
}
]
The module is configured with the following settings:
json
{
"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 suggestions?
The JSON creation prompt seems unusual. Are you using AI to format the JSON body for your request? I'd recommend swapping your destination URL with a test URL (like hookrelay, etc.) to inspect what's actually being sent.
Within your custom functions, it's recommended to utilize the native JavaScript functions JSON.stringify()
or JSON.parse()
instead of createJSON()
or parseJSON()
.
This thread was automatically closed 30 days following the last response. New replies are no longer permitted.