Reputation: 21
I have blow code and my web service works well but does not return response :
ResponseEntity<Object> reponse=null;
try {
reponse = restTemplate.exchange(url, HttpMethod.POST, requestEntity, Object.class);
} catch (HttpStatusCodeException e) {
System.out.println("reponse="+reponse);
}
my question is that, why
response
is null but
restTemplate.exchange(url, HttpMethod.POST, requestEntity, Object.class)
is not null?
Upvotes: 1
Views: 2970
Reputation: 21
I was incorrectly searching for errors in response entity. But it is available in the exception.
} catch (HttpClientErrorException e) {
System.out.println(e.getStatusCode());
System.out.println(e.getResponseBodyAsString());
}
Upvotes: 1