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

Apigee Edge: Unable to set response.content value in Postclient flow.

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:

ashutoshcupsima_1-1724161561540.png

0 4 272
4 REPLIES 4