how to post JSON ARRAY data to server in Android -


i want send below json data server , read response in android. below json data.

{     "class": "orderitemlistdto",     "orderitemlist": [         {             "class": "orderitemdto",             "orderid": 24,             "itemid": 1,             "quantity": 2,             "status": "new",             "srequest": "none"         },         {             "class": "orderitemdto",             "orderid": 24,             "itemid": 2,             "quantity": 2,             "status": "new",             "srequest": "none"         }     ] } 

here may data increased.

check code

jsonarray json = //your array; httpclient httpclient = new defaulthttpclient(); httpcontext httpcontext = new basichttpcontext(); httppost httppost = new httppost("http://your_url");  try {      stringentity se = new stringentity(json.tostring());      httppost.setentity(se);     httppost.setheader("accept", "application/json");     httppost.setheader("content-type", "application/json");       httpresponse response = httpclient.execute(httppost, httpcontext); //execute request , parse response     httpentity entity = response.getentity();      string jsonstring = entityutils.tostring(entity); //if response in json format  } catch (exception e) {     e.printstacktrace(); } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -