Imagine you have a scenario, where a user sens a json or xml payload via client eventhough the backend accepts only formdata. So you need to find a method to change the payload during the mediation without editing the API synapse configuration manualy.
E.g.,
You can simply achieve this by adding a custom mediation extension in to in flow since the default available mediation extensions do not support it.
In order to do this you have change the Content Type in to application/x-www-form-urlencoded.
Sample mediation extension :
E.g.,
{
"userid": "123abc",
"name": "Ushani",
"address ": "Colombo"
}
in to
userid=123sbc&name=ushani&address=Colombo
You can simply achieve this by adding a custom mediation extension in to in flow since the default available mediation extensions do not support it.
In order to do this you have change the Content Type in to application/x-www-form-urlencoded.
Sample mediation extension :
<?xml version="1.0" encoding="UTF-8"?> <sequence xmlns="http://ws.apache.org/ns/synapse" name="formdataconvert"> <property name="messageType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"/> <log level="full"/> </sequence>
No comments:
Post a Comment