spring-attic/spring-android

Debug log print the sent requests/response

Closed this issue · 5 comments

Hi, can someone help me, amm I need to show logs of requests sent by my app

restTemplate.setInterceptors(new ArrayList());
restTemplate.getInterceptors().add(new ClientHttpRequestInterceptor(){
@OverRide public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
ClientHttpResponse response = execution.execute(request, body);
//print response
return response
}});
Also, please consider closing this as it's not a project related issue.
I recommend into using stackoverflow.com for such questions.

@andreiverdes thanks for the help!

No problem!

Hey Guys ,

Can anyone help me to print the response that i get ?

I am using restemplate and AsyncClass for the server call

AsyncClass?
The code for printing the response is described above. You can do response.getBody() and get the response as an InputStream, turn it into String and print it. :)