Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArrayList to DavidWebb Android

I am using DavidWebb for making Http POST requests. I have ArrayList or HashMap for all the params that I want to send. How can I pass an array of params using DavidWebb?

Right now I am doing this like

Response<String> resp = webb
                    .post(Constants.URL + Constants.CUSTOMER_SIGNUP)
                    .param("username", params.get("username"))
                    .param("user_contact_no", params.get("user_contact_no"))

I want to do something like

Response<String> resp = webb
                        .post(Constants.URL + Constants.CUSTOMER_SIGNUP)
                        .arraylist/hasmap of params
like image 345
Shaheera Avatar asked Nov 11 '15 10:11

Shaheera


1 Answers

I found the solution. "Andy Turner"'s answer clicked.

Request request = webb
                    .post(Constants.URL + Constants.CUSTOMER_SIGNUP);
                    for (Map.Entry<String, String> entry : params.entrySet()) {
                        request.param(entry.getKey(), entry.getValue());
                    }
            Response<String> resp = request.readTimeout(30000)
                    .connectTimeout(30000)
                    .asString();
like image 196
Shaheera Avatar answered Sep 28 '22 02:09

Shaheera