The addition of REST service consumption to AwareIM is a huge addition to a fantastic package. We have extended our AwareIM Apps with data from numerous REST services. Thank you Vladimir.
Some of the REST services we have used with AIM return addrional information via the http response codes (aka status codes). Like the examples below :
200 OK Success
201 Created Resource was created
304 Not Modified There was no new data to return.
400 Bad Request The request was invalid. An accompanying error message will explain why.
401 Unauthorized Authentication credentials were missing or incorrect.
402 Payment required The request is not available in your current price plan.
403 Forbidden The request is understood, but it has been refused.
Is there a way to capture the http response code returned in an AwareIM REST exchange?
Dave, I’ve had this problem for a few months as well.
One rest service we use has a normal reply that gets loaded into a BO.
But sometimes, they will return an error (i.e. something other than a 200) and this will not fit the BO structure. So it gets displayed as an ugly message to the user.
I think what’s needed is an Aware methodology to allow for
a) successful reply of type JSON that will create a new instance of a BO, and
b) an error reply in the form of JSON that can create a BO instance also - Then I would be able to gracefully handle the response along with structured data from the provider to present to the user.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
I have been working on consuming a REST service for the past week and the following has been my experience with capturing the status code.
1) The BO with the attribute to capture the status code needs to already be in context of the process performing the REQUEST SERVICE
2) A status code of 200 is not captured
3) Any other status code will be captured in the attribute set up to receive the status code
4) If any status code but 200 is returned, the body of the response will be saved in the attribute set up to receive the error message
5) If the body of the response is empty, the current process will fail
Here is a quick screen shot using the latest AwareIM build. Note: only the fields for capturing the status code and any error message have been set up.
We had slightly different results, we couldn't get the result code (middle tick box) to work, so we unticked that and just left the bottom one ticked and it works.
Rod. Aware 8.6 (latest build), Developer Edition, on OS Linux (Ubuntu) using GUI hosted on AWS EC2, MYSQL on AWS RDS