RESTful communication

Cyril P.
Meung Sur Loire, France

May 16, 2019
23 Posts

0  |  0  

Re: RESTful communication


I am trying to communicate with an application that propose a REST API.
I have found an example in the knowledge base (ConsumingRESTfulServices)

It seems to work as I can receive the response body in case of positive answer from the server, but in case of negative answer I get an Ateasy runtime error.
So, I am not able to get the response body.
Is there a way to get the response body using Try/Catch and something else?

I have attached some picture to illustrate my trials.
Test_RESTful_Code.jpg : view of the Ateasy code
Test_RESTful_testlog.jpg : view of the log with the response body when it is working
Test_RESTful_Error.jpg :  runtime error on the code line ws = request.GetResponse()
Test_RESTful_4_Expected_OK.jpg : view of the working request and it's expected response
Test_RESTful_4_Expected_NOK.jpg : view of the not working resquest (because the parameter are not good) and the expected response

Thanks for your help.

File Attachment:

Solution Available
Victor B.
Lake Forest, CA

May 20, 2019
93 Posts

1  |  0  

Re: RESTful communication

Hi Cyril,

For WebRequest, the response body is embedded in the Response property of the WebException object that is being returned.  ATEasy can catch errors with a try-catch block, but it catches error numbers rather than catching Objects.

I'm thinking that you could write a .NET assembly wrapper which handles this specific behavior (creates the request, executes it, and returns the WebResponse or WebException object) and incorporate it into your ATEasy project.  
Or, more simply, you can use the ATEasy try-catch block and the built-in functions GetErrorNum() and GetErrorMsg().  These give the error code and the message that popped up at you via the error dialog box, but can be used without halting your application or requiring additional coding time.

Cyril P.
Meung Sur Loire, France

May 21, 2019
23 Posts

0  |  0  

Re: RESTful communication

Hi Victor,

thanks for your reply.
I was thinking also about your solution but I was hoping there would have another one directly inside Ateasy.

Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]