Tag: apim

Wso2 ESB/APIM add query parameter to endpoint

Lets say there is a http endpoint http://localhost:8080/restapi defined in a api and want to add query parameter in sequence level before invoking the endpoint.

i.e   http://localhost:8080/restapi?id=2&name=admin&role=admin

By using Property “REST_URL_POSTFIX” this can be achieved as follow.


<?xml version="1.0" encoding="UTF-8"?>
<sequence
 xmlns="http://ws.apache.org/ns/synapse" name="admin--test:v1--In">
 <log level="full">
 <property name="IN_MESSAGE" value="IN_MESSAGE"/>
 </log>
 <property name="id" value="2"/>
 <property name="name" value="admin"/>
 <property name="role" value="admin"/>
 <property name="REST_URL_POSTFIX" expression="fn:concat('?id=',$ctx:id,'&amp;name=',$ctx:name,'&amp;role=',$ctx:role)" scope="axis2"/>
 <endpoint
 xmlns="http://ws.apache.org/ns/synapse" name="HTTPEndpoint">
 <http uri-template="http://localhost:8080/restapi" method="GET"></http>
 </endpoint>
</sequence>