Result in bad request exception when sending json object to HTTP server in android -


i'm trying send http server exception. code i'm using in asynctask, feel have missed thats why gives exception because success in fiddler when try request. if spot mistake please me it. highly appreciated.

this request,

{"cartitementity":[{"mainmenucode":"chba","submenucode":"al","quantity":1,"price":1560}],"discountcode":"0","paycode":"0","orderid":"6592","outletcode":"at","requireddate":"15/6/2015","total":"1638.0","cardno":"0","phoneno":1234} 

this asynctask class

public class getalldiscountsasynctask extends         asynctask<jsonobject, integer, jsonarray> {     private ontaskcompleted listener;     private jsonarray responsejson = null;     private context contxt;      public getalldiscountsasynctask(context context, ontaskcompleted listener) {          // api = apiurl;         this.contxt = context;         this.listener = listener;     }      jsonobject jdata;       @override     protected jsonarray doinbackground(jsonobject... jdata) {          string parameterpass = jdata.tostring();         log.i("doinbackground", parameterpass);          string path = null;         string response = null;         defaulthttpclient httpclient = null;          responsehandler<string> responsehandler = null;          try {             path = "xxxxxxxxxxxxxxxxxxxxxxx";              new url(path);         } catch (malformedurlexception e) {              e.printstacktrace();         }          try {              httpclient = new defaulthttpclient();              httppost httppost = new httppost(path);             httppost.setentity(new stringentity(jdata.tostring(), "utf-8"));             httppost.setheader("content-type", "application/json");              responsehandler = new basicresponsehandler();             response = httpclient.execute(httppost, responsehandler);              responsejson = new jsonarray(response);             system.out.println("*****jarray*****" + responsejson.length());          } catch (exception e) {             log.e("buffer error", "error converting result " + e.tostring());         }         try {             responsejson = new jsonarray(response);          } catch (jsonexception e) {             log.e("json parser", "error parsing data " + e.tostring());         }          return responsejson;      }      @override     protected void onpostexecute(jsonarray result) {          super.onpostexecute(result);          listener.ontaskcompleted(responsejson);     }  } 

this exception get,

enter image description here

you must convert response string , make json object out of it


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -