differentiate response between two successful http status code

33 views
Skip to first unread message

kapitanluffy pirata

unread,
May 1, 2015, 8:06:19 PM5/1/15
to robo...@googlegroups.com

I am using Robospice library along with Spring for my android app. The web service that I am using has a route where it requires an email parameter and returns a user object.

It responds a 201 CREATED status code whenever the sent email will create a new user or 200 OK if the email already has an existing user.

However they both fall on onRequestSuccess() of the RequestListener. How can I differentiate the response given by the web service?


Nikola Keskinov

unread,
May 4, 2015, 6:39:17 AM5/4/15
to robo...@googlegroups.com
You should do that in your loadDataFromNetwork() method in your SpiceRequest. Using the Spring extension for RoboSpice, I guess the best way is to use any of the RestTemplate.exchange methods to execute the request, and then use any part of the ResponseEntity you need. Based on the HTTP status code, you can now return a different response that will be passed to RequestListener.onRequestSuccess() and act appropriately.

Another option is to just pass the complete ResponseEntity to onRequestSuccess() by returning it from loadDataFromNetwork(), but that is a pretty dirty hack.
Reply all
Reply to author
Forward
0 new messages