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';
qryRest.body.push(chunk);
qryRest.trigger();
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?