I've been writing an API for a project I'm working on and I've written a resource that takes a POST request, containing the type
of the request and the url
of the API, for example:
{ "test":{ "type":"DSS", "url":"http://localhost:8280/testsuite/general/test" } }
In the response, I just need the HTTP status code (200
for okay, 404
for not found, etc., etc.) but every method of getting this that I have tried has only seen it return null for the code.
I saw one post on here that posed a couple of suggestions which I've included below; neither of these worked.
<property xmlns:ns="http://org.apache.synapse/xsd" name="status" expression="get-property('HTTP_SC')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="status" expression="get-property('axis2', 'HTTP_SC')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="status" expression="$axis2:HTTP_SC"/>
For all of the above attempts, it just returns null for the value of status
.
Linked is a kobra.io page with the resource I've written on it. If anyone can offer some guidance on how to get the response code out, that'd be hugely appreciated as it's been a thorn in my side for a couple of days now..
For reference, I'm using WSO2 v4.9.