cancel
Showing results for 
Search instead for 
Did you mean: 

[REST] More info instead 'Internal server Error'

f_lombardo
Champ in-the-making
Champ in-the-making
Hi all,

I noticed that the REST API answers whith and "500 Internal server error" for each type of error in the client request. Would it be possible to get more info about what's wrong instead of this generic response?

Thanks in advance.

Bye

Franco
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
The body of the response generally contains a stack trace of the problem… What other solution do you suggest? The response-message should describe the response-code (500 Internal server error)

f_lombardo
Champ in-the-making
Champ in-the-making
The body of the response generally contains a stack trace of the problem

That sounds good, but how to get it in a Java Application using Restlet client? See this example:

  private static ClientResource getClientResource(String uri) {
    ClientResource clientResource = new ClientResource(uri);
    clientResource.setChallengeResponse(ChallengeScheme.HTTP_BASIC,
                                        "kermit",
                                        "kermit");
    return clientResource;
  }
….
    String uri = REST_URI + "process-instance/3251";
    Representation response = getClientResource(uri)
        .get(MediaType.APPLICATION_JSON); //ResourceException if process 3251 doesn't exist

In the above code I get a ResourceException that (I think) doesn't contain the body of the response.

Is there a way to get that boby with the Restlet client?

Another way to design the REST API would give a different error status, for example "404 - not found", if process doesn't exist.

Thank you very much.

Bye

Franco

frederikherema1
Star Contributor
Star Contributor
Not sure on how to get the body using Restlet, without it throwing an exception. You have a point, though about the 404 when the process ins not found. The REST-api doesn't follow pure rest-guidelines because it's not using the response-codes to the fullest potential, we need to look into this…

f_lombardo
Champ in-the-making
Champ in-the-making
The body of the response generally contains a stack trace of the problem

Are you sure? (See http://www.francolombardo.net/wp-content/uploads/500.png)

Anyway, as you said, I think that error response should be improved a bit.

Thanks.

Bye

Franco

frederikherema1
Star Contributor
Star Contributor
Indeed, error-handling should be looked at in the REST-api and also validate the error-response body: https://jira.codehaus.org/browse/ACT-1463