I've used RestTemplate to consume remote REST API and I'm getting two different responses for the same request depend on data availability.
eg:- Valid Response
User {
username,
password
}
Error Response when user not found in records.
Error {
errorCode,
errorMessage
}
And this User response has mapped using restTemplate.getForEntity("url", User.class).
Additionally handled RestTemplate Errors using ResponseErrorHandler,
Is there any way to capture both User response and Error Response using resttemplate in same time?