additionalScope error when adding JS to the body of a Rest API - object could not be cloned

hello! I'm trying to include the snippet at the end of this post in the body of a resource query to a rest API. I've tried defining additionalScope using a js query and then putting the variable as the body in the resource query as mentioned here, but when i try to execute i get the following error: 'postMessage' on 'Window': URLSearchParams object could not be cloned.

I also tried using json.Stringify and wrapping the whole thing in parentheses, while this takes the error away, i check the output of the request and i see that an empty {} is being sent as the additionalScope variable i set up when i do this. Here is the body I am trying to send:

body: new URLSearchParams({where: ‘xxx in xxx’})

Lmk if anyone can help with a solution!

Hey @jbi! The 'postMessage' error likely has to do with trying to return the URLSearchPrams object from the sandbox where the JS is run. Looks like the there is a built in toString method included on the object that is available and seems to work.

Returning the JSON.stringified version of the param object seems to return the {} that you were seeing, but using toString() give the proper result:
Screenshot 2023-12-06 at 2.41.11 PM

Syntax in the REST query:
Screenshot 2023-12-06 at 2.58.24 PM

Received by the endpoint:
Screenshot 2023-12-06 at 2.42.36 PM

Hope this helps!