java - I want to post array param in HttpURLConnection android -
i fresher in developing android apps, in app want post params in format below:
user_id=12&task_id=100&user_ids=["91","92"]
i not able send user_ids
in array format. receiving user_ids
string in rails api.
i using httpurlconnection, , in writer.write()
passing post params as
writer.write("user_id="+id+"&task_id="+tid+"&user_ids="+["91","92"]+");
please help.
if 1 facing same problem, found work around. need add array in string
1. step 1
create final arraylist<string> selectedtagids = new arraylist<string>();
and add array items using
selectedtagids.add("one"); selectedtagids.add("two"); ...
2. step 2
convert
selectedtagids.tostring();
3. step 3
format string replacing string to
selectedtagids.replace("[","").replace("]","").replaceall("\\s","").trim();
4 step 4
finally post string server (i used httpurlconnection post data server), , in server code, convert received selectedtagids array , loop accordingly achieve you'r desired result.
Comments
Post a Comment