Send a string on Android with HttpPost without using nameValuePairs -


i looking information how can send information using httppost method on android, , see this:

httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(posturl);  list<namevaluepair> params = new arraylist<namevaluepair>(); params.add(new basicnamevaluepair("name","var1")); params.add(new basicnamevaluepair("name2","var2"));  httppost.setentity(new urlencodedformentity(params));     httpresponse resp = httpclient.execute(httppost); httpentity ent = resp.getentity(); 

the problem cant that, because have connect resource receive string xml format.

any idea how can send string without using list<namevaluepair>

have tried using stringentity? above code can updated use stringentity, following resulting code:

httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(posturl);   httppost.setentity(new stringentity("your string"));     httpresponse resp = httpclient.execute(httppost); httpentity ent = resp.getentity(); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -