I have REST API URL defined as
https://hostname/[version]/[service]/[operation]
and I would like to transform JSON payload in WSO2 API Manager in order to put version and operation inside.
So the WSO2 will send it to backend in the following form:
POST https://backend/[service]
{
“version”: [version],
“operation”: [operation]
}
So I need to put version and operation from URL to JSON payload. How to do it?
As I understand you want to create a new payload and POST with values from the resource URI definition (not API context).
Lets assume:
You may want to create a (synapse) mediation flow as for ESB building such a message.
Plugging in the mediation is described in the documentation Adding Mediation Extensions . This mediation will be executed for every request of the API
Having resource https://hostname/[version]/[service]/[operation]
In the mediation, you may build the JSON payload
<payloadFactory media-type="json">
<format>{
"version":"$1",
"service": "$2",
"some_original_data": "$3"
}</format>
<args>
<arg expression="get-property('uri.var.version')"/>
<arg expression="get-property('uri.var.service')"/>
<arg expression="$.person.name" evaluator="json" />
</args>
</payloadFactory>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.