Linked Questions
36 questions linked to/from Spring RestTemplate - how to enable full debugging/logging of requests/responses?
13 votes
1 answer
34k views
How to log RestTemplate request and response with spring? [duplicate]
I'm using Spring with RestTemplate to execute HTTP GET requests. How can I log any request and response data to a log file automatically on each request?
0 votes
1 answer
340 views
Rest Template -how to retrieve raw POST request String before it's being sent [duplicate]
For debugging purposes , I need to retrieve the raw POST request of an restTemplate.postForObject method , is there any way to obtain it before it get send?
122 votes
16 answers
160k views
HttpURLConnection Invalid HTTP method: PATCH
When I try to use a non-standard HTTP Method like PATCH with URLConnection: HttpURLConnection conn = (HttpURLConnection) new URL("http://example.com").openConnection(); conn.setRequestMethod("...
46 votes
7 answers
92k views
How do I configure Spring and SLF4J so that I can get logging?
I've got a maven & spring app that I want logging in. I'm keen to use SLF4J. I want to put all my config files into a directory {classpath}/config including log4j.xml and then init using a spring ...
15 votes
8 answers
41k views
How do I log response in Spring RestTemplate?
I am using RestTemplate to make calls to a web service. String userId = restTemplate.getForObject(createUserUrl, String.class); If this fails to return a user ID I just get returned null but I don't ...
16 votes
2 answers
12k views
Is it possible to chain async calls using Guava?
I want to chain async rest service calls and have single callback when they finished. Is it possible to do it with guava?
6 votes
2 answers
16k views
Debug RestTemplate Post request
I am trying to POST to a REST-API using RestTemplate in Spring. Here is the code I am using: //Code to Post data using Rest Template List<UserVO> userList = getUsers(); RestRequestVO ...
5 votes
2 answers
6k views
Eclipse - Sonar S2629 possible false positive with new String
I'm using latest Eclipse and Sonar plugin In answer for logging there's the following line: log.debug("Request body: {}", new String(body, "UTF-8")); Which should create String only if in DEBUG ...
7 votes
1 answer
9k views
RestTemplate logging POST data
my resttemplate.exchange() failed on a POST request, with the server returning a 500 error. I tried to set the root logging level to DEBUG, but nothing was logged before the 500 error was returned. ...
8 votes
3 answers
18k views
ClientHttpResponse.getBody() throws ResourceAccessException when response code is 401
I am trying to log the request-response pairs for every request. The problem is that when the response code is 401, ClientHttpResponse.getBody() throws a ResourceAccessException and i cannot read the ...
5 votes
3 answers
13k views
GET Request Works in Postman but not with RestTemplate - SpringBoot
I have a request that is working fine when I try to send through postman. I was trying to implement the same using code where I faced an error. The code i am using - RestTemplate restTemplate = new ...
4 votes
3 answers
9k views
Logging all network traffic in Spring mvc
I have spring mvc application using RequestBody and ResponseBody annotations. They are configured with MappingJackson2HttpMessageConverter. I also have slf4j set up. I would like to log all json as it ...
7 votes
1 answer
5k views
Why my custom ClientHttpRequestInterceptor with empty response
I have done the following for my custom logging interceptor public class HttpLoggingInterceptor implements ClientHttpRequestInterceptor { private final static Logger log = LoggerFactory.getLogger(...
0 votes
3 answers
12k views
Spring RestTemplate throwing 403 Forbidden after hitting API
I have a service which invokes GET API via RestTemplate. The API is working fine when checked in Postman. it accepts 2 query params fieldList and systemId along with Authorization Token(Bearer) ...
2 votes
1 answer
5k views
How I get the HandlerMethod matchs a HttpServletRequest in a Filter
I'm writing a simple proxy app, and want mapped url will be handled by my controller, but other url (includes error) can be forwarded to another different address. So I use Filter rather than ...