# How to pass a map / array / seq to .param for HTTP POST param?

**URL:** <https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061>\
**Category:** Gatling (Open-Source)\
**Created:** [May 29, 2014, 10:56pm UTC](https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061 "2014-05-29T22:56:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Vaughn](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Jonathan\_Vaughn](https://community.gatling.io/u/Jonathan_Vaughn)\
**Post date:** [May 29, 2014, 10:56pm UTC](https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061/1 "2014-05-29T22:56:40Z")

</div>

I am trying to write a simulation which sometimes needs to assign additional POST parameters of varying number and name, depending on the product page it hit (in order to place product in cart - complex products require various options to be set).

I see there’s paramSeq and paramMap in the source code, but it looks like this may be on the Gatling 2.x branch? I can’t find any information on how to use these anyways, but I assume one just passes in a sequence / map of parameters and adds them to the POST request. Is there a way do this in Gatling 1.x? I didn’t want to write to 2.x since the API might get yanked out from under me, and now I’d rather not have to convert everything over to 2.x if I don’t have to …

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [May 30, 2014, 8:59am UTC](https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061/2 "2014-05-30T08:59:28Z")

</div>

I only have my phone with me so I can’t check, but this might be a Gatling 2 feature only. Gatling 2 snapshot is stable in terms of API (we lag on building the new website so we can release).

---

<div class="post-metadata">

**Author:** ![Alex\_Bagehot](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@Alex\_Bagehot](https://community.gatling.io/u/Alex_Bagehot)\
**Post date:** [May 30, 2014, 12:09pm UTC](https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061/3 "2014-05-30T12:09:40Z")

</div>

Hi Stéphane,

Is there anything we can do to help progress the 2.0 website?  
Thanks  
Alex

---

<div class="post-metadata">

**Author:** ![Jonathan\_Vaughn](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Jonathan\_Vaughn](https://community.gatling.io/u/Jonathan_Vaughn)\
**Post date:** [May 31, 2014, 12:51am UTC](https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061/4 "2014-05-31T00:51:37Z")

</div>

OK, I have moved to SNAPSHOT (apparently it still wasn’t even in M3a). However, what used to work for adding to the session and then passing it to the next part of the chain doesn’t, now the things I’m setting aren’t getting passed forward.

I.e., this used to work:  
exec((session: Session) =\> {  
…  
session.set(“qty”, Random.nextInt(4) + 1)  
})  
.exec(http(…)  
…  
.param(“qty”,"${qty}")

However, it complains that “No attribute named ‘qty’ is defined.” It gets past a previous .param(…) that was set via the .check before the code snippet above, so it appears that my modified session is not chaining through anymore, but items in there previously still work.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [May 31, 2014, 5:52am UTC](https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061/5 "2014-05-31T05:52:43Z")

</div>

Please double check on your side, for example for a missing dot.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Vaughn](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Jonathan\_Vaughn](https://community.gatling.io/u/Jonathan_Vaughn)\
**Post date:** [June 2, 2014, 6:44pm UTC](https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061/6 "2014-06-02T18:44:18Z")

</div>

It looks like the problem was I was doing this:  
session.set(“qty”, Random.nextInt(4) + 1)  
session.set(“bundleParams”, bundleParams)

And it wouldn’t have qty, but would have bundleParams. If I reverse the order, then the opposite is true.

However if I do this:  
session.set(“qty”, Random.nextInt(4) + 1)  
.set(“bundleParams”, bundleParams)

It appears to work fine.

I hadn’t noticed before, but it looks like this is the first time I’m trying to set and return more than one session attribute in one code block, so that’s why I didn’t do that right, I didn’t realize…

---

<div class="post-metadata">

**Author:** ![Jonathan\_Vaughn](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Jonathan\_Vaughn](https://community.gatling.io/u/Jonathan_Vaughn)\
**Post date:** [June 2, 2014, 7:55pm UTC](https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061/7 "2014-06-02T19:55:23Z")

</div>

Well, the next problem I ran into was that I wasn’t passing an immutable map into paramsMap, and it didn’t like that. Simply changing  
.set(“bundleParams”, bundleParams)  
to  
.set(“bundleParams”, bundleParams.toMap)

Solved that !

I am now successfully using .paramsMap !

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 2, 2014, 8:05pm UTC](https://community.gatling.io/t/how-to-pass-a-map-array-seq-to-param-for-http-post-param/1061/8 "2014-06-02T20:05:42Z")

</div>

However if I do this:  
session.set(“qty”, Random.nextInt(4) + 1)  
.set(“bundleParams”, bundleParams)
