Hi Apigee Community,
I want to make sure that only a select number of fields from the request body are sent to the target server. I wanted a solution that is both light and easy to maintain, preferably with the allowed fields definition centralized on only one location.
Example:
Allowed fields = [name, surname, date_of_birth]
request.content = { name, surname, age }
would turn into:
request.content = { name, surname }
What are the best solutions for this?
Thank you in advance.
Solved! Go to Solution.
You could use Javascript policy to modify the request payload.
Please see: https://community.apigee.com/questions/45357/how-to-modify-existing-value-in-json-payload-body.html
Or possibly use AssignMessage policy.
Please see: https://community.apigee.com/questions/64140/how-can-we-perform-json-to-json-transformation-usi.html
Regarding "easy to maintain" and "fields definition centralized" , I would suggest:
You could use Javascript policy to modify the request payload.
Please see: https://community.apigee.com/questions/45357/how-to-modify-existing-value-in-json-payload-body.html
Or possibly use AssignMessage policy.
Please see: https://community.apigee.com/questions/64140/how-can-we-perform-json-to-json-transformation-usi.html
Regarding "easy to maintain" and "fields definition centralized" , I would suggest:
Allowed fields can be stored in KVM. Then using KVM policy you can extract the allowed fields. Using a javascript the condition can be checked and extra content parameters can be deleted.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |