Sunday, 15 April 2012

HttpClient Error Handling Android -



HttpClient Error Handling Android -

i send requests server

public httpresponse post(string urn, string entity) throws ioexception { httppost httppost = new httppost(url + urn); httppost.setheader("content-type", "application/json"); httppost.setheader("accept", "application/json"); httppost.setentity(new stringentity(entity, http.utf_8)); homecoming httpclient.execute(httppost, httpcontext); }

to create new business relationship phone number sent server , validated. if number not valid 400 bad request error returned.

within response server json object returned in content. has details of why 400 error returned. typical json response this

{"dev_message": "the number 93015205229804 isn't valid mobile number.", "user_message": "invalid phone number", "error_code": 108}

the execute method throws ioexception when 400 error returned. how can go getting message httpresponse if error automatically thrown?

android httpclient

No comments:

Post a Comment