I want to delete the *params* property from the response body. I've tried a javascript callout, but haven't been able to identify the correct variable / syntax to remove it. I also tried assign-message policy but that seemed to only be for headers and query params.
{ "action": "get", "application": "abc", "params": { "client_secret": [ "my_secret" ], "client_id": [ "my_id" ] }, "path": "/parts", "uri": "https://www.google.com", "entities": [ ...]...}
Solved! Go to Solution.
var r = JSON.parse(context.getVariable('response.content')) delete r.params context.setVariable('response.content', JSON.stringify(r))
Give that a try. For better robustness, probably good to throw a hasOwnProperty check in there first.
(This has the precisely correct number of semicolons...)
var r = JSON.parse(context.getVariable('response.content')) delete r.params context.setVariable('response.content', JSON.stringify(r))
Give that a try. For better robustness, probably good to throw a hasOwnProperty check in there first.
(This has the precisely correct number of semicolons...)
Looks really good, except.... not enough semicolons.
Please add some.
Looks like @jasonbrown is trying to delete from the response body.
You can try using this JS policy on the Response flow
var obj = response.content.asJSON; if(delete obj.params){ response.content = ''; response.headers['Content-Type'] = 'application/json'; response.content.asJSON = obj; }
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |