Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

set variable in request content using javascript policy

Dear All,

In my flow, i have a javascript policy which gets a flow variable, modify the value and setings the new value in a field in request (which will overwrite preexisting value). Below is my javascript policy which set the variable. And then nodejs script will take request content and read the variable to prcess further in node.js.

But when I ran, i am getting 400:Bad request. Can anyone please help me to sort this out.

var changeVal = context.getVariable("flowVar1");

var req = JSON.parse(context.getVariable("request.content"));

req.field1 = changeVal;

context.setVariable("request.content", JSON.stringify(req));

When I checked trace, found that request body doesnt exists in Request sent to target server but surprisingly request content body is available in Target Request Flow Started (javascript set value policy) with changed value.

Any help would be appreciated!

Thanks

Joydeep

0 4 10.8K
4 REPLIES 4