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

delete json property from response body

Not applicable

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 Solved
1 3 3,133
1 ACCEPTED 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...)

View solution in original post

3 REPLIES 3