I/O exception in post JSON android -


i sending post request using http client ... m getting i/o exception... can any1 plz me... struggling code ...

public jsonobject makehttprequest(string url, string method, list params) {

    // making http request     try {          stringbuilder url= new stringbuilder(url);          // check request method         if(method == "post"){             // request method post             // defaulthttpclient             system.out.println("i m in post method");             defaulthttpclient httpclient = new defaulthttpclient();             httppost httppost = new httppost(url.tostring());             httppost.setentity(new urlencodedformentity(params));             httppost.setheader("accept", "application/json");             httppost.setheader("content-type", "application/json");              httpresponse httpresponse = httpclient.execute(httppost);             int status=httpresponse.getstatusline().getstatuscode();             system.out.println("if 200 ok... n "+status);                             if(status==200){             httpentity httpentity = httpresponse.getentity();             jsonstring=entityutils.tostring(httpentity);             jobj = new jsonobject(jsonstring);             }         }     } catch (clientprotocolexception e) {         system.out.println("1st exception");         e.printstacktrace();     } catch (ioexception e) {            system.out.println("2nd exception");         e.printstacktrace();     }catch (jsonexception e) {         system.out.println("3rd exception");         e.printstacktrace();         }     return jobj;  } 

}


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -