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
java spring rest spring-rest


source to share


No one has answered this question yet

See similar questions:

84
Spring Resttemplate exception handling
4
Spring Client client exception handling

or similar:

2480
How do I send JSON data using Curl from terminal / command line to Test Spring REST?
1695
How to use java.net.URLConnection to trigger and process HTTP requests
1249
How does the Java loop for each loop work?
544
Understanding REST: Verbs, Error Codes and Authentication
249
RESTful Authentication over Spring
128
Spring REST Boot Service Exception Handling
84
Spring Resttemplate exception handling
3
Spring endpoint to endpoint using RestTemplate exception handling
1
The ResponseEntity object with the error status code returned by the Rest service in its response always throws an exception in the caller
0
RestTemplate spring issue



All Articles
Loading...
X
Show
Funny
Dev
Pics