Search code examples
androidspringandroid-annotations

AndroidAnnotations restClient get responsebody of 404 error


I am doing an API call but the API sends back an error with the status code 404. How can I get the response of the API so I can see what the exact error is?

The error I am getting is:

08-12 09:52:05.977  11040-11221/eu.app W/RestTemplate﹕ POST request for "http://hidden-api-url.com" resulted in 404 (Not Found); invoking error handler
08-12 09:52:09.051  11040-11221/eu.app E/AndroidRuntime﹕ FATAL EXCEPTION: pool-5-thread-3
    Process: eu.app, PID: 11040
    org.springframework.web.client.HttpClientErrorException: 404 Not Found

Solution

  • I found the solution. I caught the HttpClientErrorException and got the response with getResponseBodyAsString();.

        try {
            restClient.restCall(data);
        } catch (HttpClientErrorException e) {
            Log.d("Response",e.getResponseBodyAsString());
        }