1

how to post multiple parameter android Volley
** post multiple array as like 101,102,103 params.put("sessionid", 101,102,103); //as like **
any other Way

 public void postCompanyArticle() {
 StringRequest stringRequest = new StringRequest(Request.Method.POST, config.postArticleTopBiz(), new Response.Listener<String>() {
 @Override
 public void onResponse(String response) {
 list = parseResponse(response);
 adapter.setList(list);
 }
 }, new Response.ErrorListener() {
 @Override
 public void onErrorResponse(VolleyError error) {
 errorJson.setVisibility(View.VISIBLE);
 String msg = VolleyException.getErrorMessageFromVolleyError(error);
 errorJson.setText(msg);
 }
 }) {
 @Override
 protected Map<String, String> getParams() throws AuthFailureError {
 Map<String, String> params = new HashMap<>();
 params.put("sessionid", 101,102,103);//as like
 params.put("EntID", "7");
 params.put("offset", String.valueOf(countView));
 params.put("limit", "10");
 params.put("LastLoginTime", "2016-02-01");
 return params;
 }
 };
 requestQueue.add(stringRequest);
}
Vadim Kotov
8,2848 gold badges51 silver badges63 bronze badges
asked Feb 6, 2016 at 10:10

1 Answer 1

2

just use for loops and it works fine.

@Override
 protected Map<String, String> getParams() throws AuthFailureError {
 Map<String, String> params = new HashMap<>();
 for(int i=0; i < arraylist.size; i++)
 {
 params.put("sessionid["+i+"]",String.valueOf(arraylist.get(i)));
 }
 params.put("EntID", "7");
 params.put("offset", String.valueOf(countView));
 params.put("limit", "10");
 params.put("LastLoginTime", "2016-02-01");
 return params;
 }

arraylist is the list of your sessionid. This works for me.

answered Feb 6, 2016 at 10:26
Sign up to request clarification or add additional context in comments.

3 Comments

Well In my case its not working since the data being posted in server changes square brackets [] to its html code i.e %5B and %5D
@PradeepKumarKushwaha you need to convert %5B and %5D on server side and its working fine.
@AndyDeveloper Why its getting only the last index value?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.