API Response for monday.com

Im trying to set an api response to the following (to get it to work with monday.com as the initial setup needs a response to verify) but i cant seem to get it to work, definitely me not doing it right! Basically i need to return the payload that i receive from Monday i think which is { “challenge” ; “xxxxxxxxx”} but i cant work out where in the $result script i put it.

Hello :slight_smile:

Welcome to the community!

exit your script with something like this

{
  "useScriptResult": true,
  "status": 200,
  "statusMessage": "OK",
  "headers": { "Content-Type": "application/json" },
  "body": {"challenge" : "xxxxxx"}
}

Here is a link to the docs that covers this

Let us know how it goes

Thanks

Todd

I figured it was something like that but do i literally just paste that into the script as

“{
“useScriptResult”: true,
“status”: 200,
“statusMessage”: “OK”,
“headers”: { “Content-Type”: “application/json” },
“body”: {“challenge” : “xxxxxx”}
}”

or does it need to sit in within this script step somewhere? JSONSetElement ( “{}”; “success”; True; JSONBoolean )

If you just paste that do you not need to escape the JSONObjects
“headers”: { \“Content-Type\”: \“application/json\” },

or use JSONSetElement judiciously

Shouldn’t that read you 'DO" need to escape the JSON Objects? I would always prefer using the JSON Set Element functions - especially seeing as (presumably) the ‘xxxxx’ string is going to need to be set to something more meaningful?

am i doing something totally wrong here??

JSONSetElement ( $result ;
[ “useScriptResult” ; “true” ; JSONString ] ;
[ “status” ; “200” ; JSONString ] ;
[ “statusMessage” ; “OK” ; JSONString ];
[ “headers” ; " { \“Content-Type\”: \“application/json\” }" ; JSONString ];
[ “body” ; "{\“challenge\” : "& JSONGetElement ( OttoReceiverInbox::Payload ; “challenge” ) & “}” ; JSONString ])

The inbound request that i need to turnaround and send back from payload is:
{“challenge”:“v2zC4fLUeEy4LG-B6_1sHfHPTqwxslhxfFF-zUX6-uifWEU9bBUkNVjpIYa8akGVc0_8Cyc0Un8ofIPd-osk9w”}

? assuming that True is indeed a boolean