Search code examples
androidandroidhttpclient

Send array in http Post request Android


I want to send string array data via post request to server from android. request parameters should be like this string array e.g.

["56e7e4ade","56e7e435ade"]

I am sending with this

for(int i=0; i<connectedpeople.size(); i++)
    {
      nameValuePairs.add(new BasicNameValuePair("myarray[]", connectedpeople.get(i).getObjectId()));
    }

But that doesnt work. can anybody give suggetion to this?


Solution

  • I have used simple JsonArray to post data and its worked. No need to use namevalue pairs or JsonObject.

    JSONArray myarray = new JSONArray();
     for(int i=0;i<favoritesUserList.size(); i++){
         myarray.put(favoritesUserList.get(i).getObjectId());
     }
    new getUserData().execute(myarray);
    

    Thanks a lot Guys.