Hello Community
I would like to know if it is possible in API gateway (v10.11) to modify native API JSON response by adding one or more JSON fields/attributes in that response (native API’s response)?
This addition is required before our API sends final response to the consumer. For example, this addition of new fields to native response can be done in response processing stage.
Suppose original native API response is as following:
{
“employee”: {
“id”: 1,
“name”: “MyName”,
“dept”: “HR”,
“type”: “permanent”
}
}
Now, suppose I want to add one new JSON field (e.g. “age”) in above mentioned JSON response at run time, so that final response of our API becomes something like following:
hi @Mubarik ,
The transformation policies (Request Transformation and Response Transformation) supports transformation of payload only using XSL Transformation. If you are using the on prem version of API Gateway and you want to do the payload transformation without using XSL files, by directly setting a value for the payload, you can use the webMethods Invoke IS policy in API Gateway.
I would advise against doing this. In general, API Gateway should be a “gatekeeper” not an active participant. Pass things through, don’t manipulate things – let whatever implements the API do that.
Of course there are times and scenarios where API GW is the only spot available where you might have control to do something. But if at all possible, have the “do something” be elsewhere.
Hello @Vikash_Sharma1
Thanks for your response. Invoke IS policy seems viable solution. Can you pls let me know few high level steps to add a json attribute in existing request payload inside “flow” service?
I know how to access request payload inside flow service when using Invoke IS policy.
However I am not sure how to add json attribute to that captured payload inside flow service. Please note that here I am requesting info about few very high level steps only (just to get an idea/direction).
Once I get high level idea/direction to do it inside flow service then I can work on details using webMethods documentation.
Thanks
Hi @Mubarik,
It all depends upon what all actions and transformation you want to implement on the request payload.
One of the ways could be append the document inside the flow service and then map that appended document with the output of the flow service.