android - How to post pameters with authentication in http post with specific key values pair? -
android - How to post pameters with authentication in http post with specific key values pair? -
try { string auth = android.util.base64.encodetostring((“username” + ":" + “password”).getbytes("utf-8"), android.util.base64.no_wrap); httpparams httpparameters = new basichttpparams(); httppost request = new httppost(“url” + ” ? action = xxx”); request.addheader("authorization", "basic " + auth); httpparameters.setparameter("password", "xxxx"); httpparameters.setparameter("email", "xxxxxxx"); httpconnectionparams.setsotimeout(httpparameters, socket_timeout_ms); httpclient client = new defaulthttpclient(httpparameters); httpresponse response = client.execute(request); string userauth = entityutils.tostring(response.getentity()); log.i("", "data. in login.." + userauth); } grab (exception e) { log.i("", "error.." + e); }
here, set per output parameters not getting @ server side...
try code
httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(this.url); { list<namevaluepair> namevaluepair = new arraylist<namevaluepair>(); namevaluepair.add(new basicnamevaluepair("requestcode", "10")); namevaluepair.add(new basicnamevaluepair("devicetype", "phone")); namevaluepair.add(new basicnamevaluepair("locale", "in")); namevaluepair.add(new basicnamevaluepair("username", "amrit@pqr.com")); namevaluepair.add(new basicnamevaluepair("password", "abc")); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); statusline statusline = response.getstatusline(); int statuscode = statusline.getstatuscode(); log.d("restclient", "status code : " + statuscode); httpentity entity = response.getentity(); log.d("response", entityutils.tostring(entity)); }
android json authentication base64 http-parameters
Comments
Post a Comment