How Springs RestTemplate handles error responses in postForEntity ()

I have a Spring service calling a Spring endpoint to rest with RestTemplate.postForEntity

. I can go through the Rest controller and see what it creates and returns ResponseEntity

with a 500 status code - Internal server error expected in my use case. However, the calling Spring service is throwing RestClientException

rather than receiving ResponseEntity

with a status.

Drops RestTemplate.postForEntity

RestClientException

when received ResponseEntity

with a status other than 2xx?

+3


source to share





All Articles