I have a REST API created on integration studio, I send back a response using the following tag:
<format> "Some response" </format>
Is is possible to set an environmental variable as the response? So that I can change my response without having to redeploy the API.
CodePudding user response:
You can use the get-property expression in the Payload factory to read the response from an environment variable as follows,
<payloadFactory media-type="text">
<format>"$1"</format>
<args>
<arg evaluator="xml" expression="get-property('env', 'property_name')"/>
</args>
</payloadFactory>
Depending on your requirement you may need to change the media-type
as well.
For more information about PayloadFactory
mediator check the following official docs
https://ei.docs.wso2.com/en/latest/micro-integrator/references/mediators/payloadFactory-Mediator/