-3

I am currently using springframework for consuming webservices in android. All was working fine but now I have been stuck. I need to consume response even when there is some bad condition i.e. even if there is status code 400 , 404, etc. Is there someone who could get me out of this trouble as I don't want to switch for any other library.

result=RestTemplateUtil.getRestTemplateForHeaders() .postForObject(url,reques‌​t,responseType,map);
  • can you please add some code sample and you have done so far! – Akshay Shinde Oct 05 '15 at 06:46
  • result=RestTemplateUtil.getRestTemplateForHeaders() .postForObject(url,request,responseType,map); it is working fine when response status is 200 but when it is 400 or somethinbg else it is returning response status but object is null. – Priyank Android Oct 05 '15 at 06:54

1 Answers1

1

You need to implement a custom org.springframework.web.client.ResponseErrorHandler and configure your RestTemplateUtil to use it as an error handler.

More details in this article here spring-resttemplate-overriding-responseerrorhandler

Community
  • 1
  • 1
Filip
  • 1,214
  • 10
  • 19
  • 1
    You are a real champ Flip. You saved my day. It was my first question on stackoverflow and now I am a fan of it just because of you. – Priyank Android Oct 05 '15 at 08:30
  • Same thing happened to me a while back :) an you'll see that soon enough you'll also be helping out others as well! – Filip Oct 05 '15 at 08:44