Adding a disclaimer in Apigee to a backend response in post flow

Looking for some advise here from the community in the best way to approach this.

I might need to add a disclaimer (text) wording/sentence to a backend json response that then customers would see in the json payload response.

Still talking to legal in respect to exactly where this needs to be because can be added to the header using the assign message policy which i have tried and yes does work.

Can the assign message policy also be used to add text to a backend response as i tried but that didnt work no , and would the assign message policy actually be the best policy to use here?

At the moment asking to see what others have done in this scenario and which worked better?

0 2 137
2 REPLIES 2

AssignMessage will work nicely to inject a header, with the name and value of your choosing. AssignMessage will not be effective for injecting a field into a JSON payload, nor an element into an XML, and so on. 

For the json case I’d suggest a JavaScript policy that looks like this:

 

var c = JSON.parse(context.getVariable(‘response.content’));

c.newField = “disclaimer text here”;

context.setVariable(‘response.content’, JSON.stringify(c));

 

Ps: why do you have a Suzuki logo for your avatar? Are you a gixxer rider ?