We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Martin Smith • 8 years ago

Hi Brendan,

Using a RestTemplate to call this REST service, how would one handle getting back different response Objects (Product/ApiErrorsView) depending on the outcome? Especially if the response was a HttpEntity with a generic type.

Nice article.

Martin

Brendan Benson • 8 years ago

In this example, invalid responses will be sent with a 422 Unprocessable Entity error code (see the last line of ApiValidationExceptionHandler). For RestTemplate, you can set up a custom ResponseErrorHandler and deserialize the response accordingly.

Does that help?

Martin Smith • 8 years ago

I'm not that familiar with ResponseErrorHandler. I'll try and check it out when I have some spare time.

Thanks