How to add a variable to a Rest Message's Content field dynamically?

Nisar2
Mega Guru

I've a rest message function defined with some default variables:

Nisar2_0-1689850491483.png

So via script, I can substitute those values

var rm = new sn_ws.RESTMessageV2('dummyAPI', 'post');
rm.setStringParameter('callback_url', 'xxxxxxxx');
rm.setStringParameter('correlationId', 'yyyyyyy');

But is it possible to add an extra variable and substitute it on the fly? Something like below:

rm.setStringParameter('new_variable', 'abc');

I tried with the above code, but in the scripted rest API resource, when I did

gs.log(JSON.stringify(request.body.data));

I could only see "callbackUrl" and "correlationId" keys and not "new_variable".

 

Is there way to have that added? I don't want to update the rest message's "Content" field and would like to have that extra variable added by script.

5 REPLIES 5

No. This way allows you to differentiate between the Prod / Sub Prod endpoint also allowing individual testing and de-coupling between the two. Easier to enhance going forward if needed and generally in my opinion better practice.