0

In the controller, I use

JsonNoderesponse = restTemplate.getForObject(url, JsonNode.class)

However I got a 'Cannot extract response: no Content-Type found' exception.

After debugging, I found the error comes from HttpMessageConverterExtractor.extractData() where the respose.getHeaders().getContentType() is null.

So I want to print out the header to see what is missing. Is there a way I can do that?

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Yifei Xu
  • 23
  • 2
  • Use `getForEntity` instead of `getForObject`. – Tim Dec 20 '16 at 20:16
  • My controller calls a backend REST app.The controller code is: private RestTemplate restTemplate; response = restTemplate.getForObject(RESTAPPURL, JsonNode.class); I verify that the rest app is working fine. But the getForObject function throws a 'no Content-type' exception, so I couldn't get any response from the controller. – Yifei Xu Dec 20 '16 at 21:47
  • The exception traced back to HttpMessageConverterExtractor.extracData(ClientHTTPResponse) fucntion in restTemplate.excute(). in extractData() function, response.getHeaders().getContentType() ==null and throws the exception. So I am wondering if there is a way I can get the response header before the exception – Yifei Xu Dec 20 '16 at 21:51

0 Answers0