Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Error response for service

I have a rest service call that responds as expected using the service test facility.

The error response (in the case of an error) gives for example:

pre{
"status": 401,
"uri": "http://owd.comp-solutions.org.uk/instructor/login",
"response": {
"error": {
"code": 401,
"message": "Unauthorised"
}
}
}/pre

If I try to execute the sevice from my app, although an error condition occurs, i do not get the expected error response, and my error handling code fails. The json reponse I am getting (using breakpoints in chrome) are as follows

pre{
"code":"PTCT022",
"description":"Error while sending request: null"
}/pre

When the call is a successful call it works correctly. Why am I getting this spurious error message when executing the function from my app (in the chrome browser on test).

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Error response for service

Hello Terry,

Please clarify, where exactly does it work, on the service test tab? Could you provide us screenshot with mapping of that service?

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Error response for service

To Clarify, it is a login screen, connecting to an external database. If you enter correct login details, then it works correctly. if you enter incorrect details, then it causes an exception which returns status 401 "Unauthorized" as shown in the above error condition. This works on the test tab of the service definition.

In the app, if the correct login details are sent, it logs in as accepted, however, if incorrect login details are entered, it does cause an exception, but the jqXHR.responseJSON does not contain the expected error information, (see second code block above).

Here are the service settings:

Image

Image

Image

The following shows the request and response mappings:

Image

Image

Here is the javascript to handle the error condition (on Error):

Image

This javascript fails because jqXHR.responseJSON.error does not exist, as the error response is incorrect.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Error response for service

FYI alertError() is just a simple popup div which shows an error message.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Error response for service

This server might accept query parameters instead of body, please move "adinumber" and "password" to the query string tab

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Error response for service

I wrote the rest service myself and it expects the parameters in the body.

Here is proof that it works correctly:

First using a valid login:

Image

Then the invalid login:

Image

It is only when I run it from the app that it fails.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Error response for service

During a valid login, the app works ok, returning the correct values, but it returns the wrong response for an invalid login.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Error response for service

It looks like a server side issue. Could you clarify, what response do you expect to get with incorrect login? Could you test it in any 3rd part Rest client?

leven.steve
Posts: 0
Joined: Sun Mar 04, 2012 4:01 pm

Error response for service

Have you tried using PostMan to test your REST service?
https://www.getpostman.com/

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

Error response for service

The responses shown above by appery test option are correct and postman gives the same results, also correct. It is only when I call the service from my app that it fails and then only when the login details are incorrect.

Return to “Issues”