I tried this but it is giving Error: “Execution of JavaScript-1 failed with error: Javascript runtime error: "SyntaxError: Empty JSON string (Script_1_js#1). at line 1 "”
var getPayload = JSON.parse(context.getVariable("request.content"));
print("getPayload::::" +getPayload);
var str = context.getVariable("getPayload.Url");
var n = false;
if(str !== null){
var n = str.includes("xyz");
}
if(n)
print("n::::" + n); //here I want to apply OAUTH Policy
else{
print("n::::"+n);
}
Can you please look into this if I am missing anything?
For some reason, the “request.content” is null. Can you please put a null check ? If it does not work, can you please try context.getVariable(“message.content”)?
Could you please add another print statement to see what is the content of “request.content”?
print(context.getVariable(“request.content”));
Because from the error you are getting, it looks to me at that stage in the flow the request body is empty, and not the one that you posted in your comment.
Now I am getting payload but not able to read parameter from that
var getPayload = context.getVariable('request.content');
print("getPayload::::" +getPayload); // it is printing 'abc.xyz.com'
var str = context.getVariable("getPayload.Url");
print("str::::" +str); //it is null