I am trying to set response.content value from null or empty to "" using JS in post client flow before logging in the splunk.
Not able to replace and set the value of response.content.
Refer the below code snippet. Additionally, in the trace I see Not="" in response.content.
JS Code:
Refer else Part.
function isValidJSON(inputContent){
try{
JSON.parse(inputContent);
return true;
}
catch(error){
return false;
}
}
var responseContent = context.getVariable("response.content");
if (responseContent){
if(!isValidJSON(responseContent)){
responseContent = "'"+responseContent+"'";
context.setVariable("response.content", JSON.stringify(responseContent));
}
}
else{
context.setVariable("response.content", JSON.stringify(''));
}
Trace Screenshot: