Rest Assured -> How to pass query param or form param having array items so that all options should get pass

360 views
Skip to first unread message

deepak mathpal

unread,
Aug 19, 2021, 4:13:38 AM8/19/21
to rest-a...@googlegroups.com
Hi All,

I have a request where one of the params needs to be passed in below format.

"DistributionChoices": ["ABC.com", "JPQ.com", "N\A"]

When I am doing post request with queryParams and passing:

queryParam.put("DistributionChoices", Arrays.asList("ABC.com", "JPQ.com", "N\A"));

or

formParam("DistributionChoices", Arrays.asList("ABC.com", "JPQ.com", "N\A"));

in this format, then in response (with a post request), Only 1 value is coming. 

What needs to be done here so that it can take all values?

Below is sample code:

List<String> items = Arrays.asList("ABC.com", "JPQ.com", "N\A");

RestAssured.base = "baseURI";
Map<String, Object> queryParams = new HashMap<>();
queryParams.put("apiKey","apiKeyValue");
queryParams.put("name","nameValue");
queryParams.put("description","descriptionValue");

queryParams.put("distrbutionChoice",items); // Here is the issue

RestAssured.given().params(queryParams);

Response response = request.when().post();
Stackoverflow question for the same: https://stackoverflow.com/questions/68813546/rest-assured-how-to-pass-query-param-or-form-param-having-array-items-so-that/68814140?noredirect=1#comment121650435_68814140

Regards,
Deepak Mathpal
07208467902
Reply all
Reply to author
Forward
0 new messages