Results 1 to 2 of 2

Thread: RestTemplate Client exchange expects different response body for ResponseErrorHandler

  1. #1
    Join Date
    Nov 2011
    Posts
    17

    Default RestTemplate Client exchange expects different response body for ResponseErrorHandler

    Hi,

    I am using RestTemplate as a Client to a server. I use RestTemplate.exchange to send the HTTP POST and indicate that I expect a specific object for the response body. However, if there is a failure on the server side, the server will respond with a response statuscode of 4xx or 5xx and will include an error object in the response body.

    I cannot figure out in RestTemplate ResponseErrorHandler how to process an 4xx or 5xx error and map the response.getBody() to an expected error response object. Anyone have any ideas? Is this supported in Spring?

    Thanks,
    Brian

  2. #2
    Join Date
    May 2011
    Location
    Madrid (Spain)
    Posts
    101

    Default

    Hi, you can see here a workaround.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •