Skip to content
POST CALL JSON REST...
 
Notifications
Clear all

POST CALL JSON REST API Call returns 400 with module

4 Posts
3 Users
0 Reactions
3 Views
Juraj_Puchky
(@juraj_puchky)
Posts: 1
New Member
Topic starter
 

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?

 
Posted : 27/09/2024 10:08 am
api-guy
(@api-guy)
Posts: 2
New Member
 

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.

 
Posted : 27/09/2024 4:52 pm
api-guy
(@api-guy)
Posts: 2
New Member
 

Within your custom functions, it's recommended to utilize the native JavaScript functions JSON.stringify() or JSON.parse() instead of createJSON() or parseJSON().

 
Posted : 27/09/2024 6:50 pm
system
(@system)
Posts: 332
Reputable Member
 

This thread was automatically closed 30 days following the last response. New replies are no longer permitted.

 
Posted : 27/10/2024 6:51 pm
Share: