0

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.

Community
  • 1
  • 1
Olly John
  • 366
  • 5
  • 20
  • That didn't work unfortunately. I spoke with my immediate superior and he said to just hardcode the values as if it's returning anything that isn't a failure, it'll have a 200 code due to the setup of the platform we're working from so, while not an ideal solution, that's what we had to go with. – Olly John Dec 03 '15 at 09:44
  • 1
    have you tried to log the status code ? if it's correctly coming from the service you are calling? like this , you can enable wire logs to see if the status is coming correctly – Rahul Dec 17 '15 at 06:02

0 Answers0