REST http response codes

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
UnionSystems
Posts: 197
Joined: Fri Jun 17, 2016 7:10 am
Location: Brisbane Australia
Contact:

REST http response codes

Post by UnionSystems »

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 :

Code: Select all

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?
AWS Linux, Windows Server, AIM 8.4 & 8.6
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: REST http response codes

Post by Jaymer »

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.

Jaymer
Aware Programming & Consulting - Tampa FL
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: REST http response codes

Post by BenHayat »

@Support,
I'm going through the docs for a Payment Processing, and they ONLY supply status code.
A successful request returns the HTTP 202 Accepted status code
We NEED status codes in order for our side to make decision what to do. Every REST system follows this standard. A message is not the standard way.

Please upgrade the REST system to send/get Status code as this is a required featured by many Payment processing sites.
UnionSystems
Posts: 197
Joined: Fri Jun 17, 2016 7:10 am
Location: Brisbane Australia
Contact:

Re: REST http response codes

Post by UnionSystems »

Vlad delivers (again).

New 8.2 build 2561 changelog

Code: Select all

Improvements:
1. It is now possible to capture HTTP response codes in REST
We have not used it yet, but thank you Vlad.
AWS Linux, Windows Server, AIM 8.4 & 8.6
UnionSystems
Posts: 197
Joined: Fri Jun 17, 2016 7:10 am
Location: Brisbane Australia
Contact:

Re: REST http response codes

Post by UnionSystems »

Hello

Can someone tell me how these HTTP response codes are captured in the AwareIM REST setup ?
AWS Linux, Windows Server, AIM 8.4 & 8.6
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: REST http response codes

Post by BobK »

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
Bob
UnionSystems
Posts: 197
Joined: Fri Jun 17, 2016 7:10 am
Location: Brisbane Australia
Contact:

Re: REST http response codes

Post by UnionSystems »

Thanks for quick reply Bob.

Can you post a screen shot of where in the AwareIM REST screens you defined the BO and attribute to capture the http status code?
AWS Linux, Windows Server, AIM 8.4 & 8.6
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: REST http response codes

Post by BobK »

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.
rest.PNG
rest.PNG (130.93 KiB) Viewed 10907 times
Bob
RLJB
Posts: 914
Joined: Tue Jan 05, 2010 10:16 am
Location: Sydney, Australia

Re: REST http response codes

Post by RLJB »

Bob! very helpful post thanks.

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
Post Reply