java - How to pass an List<Integer> Object and String in Rest Services in Android -
hi woring quiz app, need call post rest services(json),below 1 sample code not working
i need pass 3 thing parameter 1-userid, 2-list questionids , 3- list answerids. question how pass list object not string or json string here-
list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("userid", "121213")); namevaluepairs.add(new basicnamevaluepair("questionsids", listobj); namevaluepairs.add(new basicnamevaluepair("answerids", listobj)); httpclient httpclient=new defaulthttpclient(); httppost httppost = new httppost(url); httppost.setheader(http.content_type,"application/x-www-form-urlencoded;charset=utf-8"); try { httppost.setentity(new urlencodedformentity(namevaluepairs, "utf-8")); } catch (unsupportedencodingexception e) { e.printstacktrace(); }
is there other way call post rest service.how resolve above one?
thanks ranjan.
use loop , add same key.
like this:
list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); (modelassignee assignee : assignmentchips.getassignees()) { namevaluepairs.add(new basicnamevaluepair("assignedtoids", string.valueof(assignee.id))); }
Comments
Post a Comment