Hi I am woring for a Quiz App, so I need to call post rest services(json),below one is my sample code which is not working
I need to pass 3 thing as parameter 1-userid, 2-List questionids and 3- List answerIds. My Question is how to 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 any other way to call the post rest service.How to resolve above one?
Thanks Ranjan.
Aucun commentaire:
Enregistrer un commentaire