Set a value for the back end response of an API WSO2 ESB 5.0.0 (Set the response message from 202-Accepted to 200-OK)

Dilsi Chandrasena
1 min readOct 26, 2017

--

This blog is related to the WSO2 ESB 5.0.0.

Below Test1 is an API created with a mocky backend.

<api xmlns=”http://ws.apache.org/ns/synapse" name=”Test1" context=”/test1">
<resource methods=”POST GET”>
<inSequence>
<send>
<endpoint>
<address uri=”http://www.mocky.io/v2/59f60737310000550860026a"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>

When we invoke above API using curl command, an output is 200 OK.

(curl http://localhost:8280/test1 -v)

But, if we want to change and set a new value for the response we can use HTTP_SC property as below. (We have changed the response here, from 202-Accepted to 200-OK)

<api xmlns=”http://ws.apache.org/ns/synapse" name=”Test1" context=”/test1">
<resource methods=”POST GET”>
<inSequence>
<send>
<endpoint>
<address uri=”http://www.mocky.io/v2/59f60737310000550860026a"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<property name=”SC_ACCEPTED” value=”false” scope=”axis2" type=”BOOLEAN”/>
<property name=”HTTP_SC” value=”200" scope=”axis2"/>
<send/>
</outSequence>
</resource>
</api>

Now we can get the new response with 200-OK.

--

--

Dilsi Chandrasena
Dilsi Chandrasena

No responses yet