php - Array params in Volley StringRequest -
i have trouble sending stringrequest. 1 of params must array
here request:
public void sendtowebservice(final string login, final string mdp, final reprise rep){ string url = myapplication.geturlws(); final requestqueue request = requestqueuesingleton.getinstance().getrequestqueue(); stringrequest sr = new stringrequest(request.method.post, url, new response.listener<string>() { @override public void onresponse(string response) { rep.setstatus(1); reprisedao db = new reprisedao(context); db.addvehicule(rep); } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { } }){ @override protected map<string,string> getparams(){ map<string, string> params = new hashmap<string, string>(); params.put("login", login); params.put("password", mdp); ... jsonarray jarray = new jsonarray(); (equipement equ : rep.getequipements()) { jarray.put(equ.getid()); } string data= jarray.tostring(); params.put("caroptions", data); params = checkparams(params); //this put empty string if param null return params; } }; request.add(sr); }
this php code of webservice. show interesting part:
foreach($_post['caroptions'] $v) { $query_options='insert cars_options_car (carid, optionid) values (' . (int)$lastid . ',' . (int)$v . ')'; $request_options=mysql_request($query_options); }
as can see, webservice expect receive array in "caroptions" param. after little research, i've tried make jsonarray , convert string. request received webservice seems array not converted.
should use other kind of request ? i've tried jsonrequest seems webservice doesn't accept jsonrequest.
Comments
Post a Comment