Dynamically adjusting the body property of a REST POST query

If I have a REST query in my tool and have set it to be of type POST, when I write a custom snippet of Javascript to trigger on button click, how to I modify the contents of the POST body in the snippet?

For example, let's say I want the POST body of a call to include a key of foo with a value of bar. Assume that qryRest is my REST query component. I thought it would be as straightforward as something like:

let chunk = {};
chunk.key = 'foo';
chunk.value = 'bar';

However, when I console.log() the metadata property of this query object, the body is empty and unchanged:

I'm assuming that the body property (of type Array) is the one I should be manipulating, but that doesn't appear to be correct. Furthermore, there doesn't appear to be a request property (in which I might further adjust a body property).

So...what is the correct syntax to manipulate the body, prior to making the REST query trigger?

Hey @Wrapmate,

Almost, you can't pass data to a query BEFORE you run it. You need to pass data AS you run it. AdditionalScope is what you need.

You're query would look something like this:

  additionalScope: {
    foo: 'bar'

In your qryRest you can now access {{ foo }} which you would put in the body.

Does that help?