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

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 …

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).

Hi Stéphane,

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

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)


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.

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

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…

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)
.set(“bundleParams”, bundleParams.toMap)

Solved that !

I am now successfully using .paramsMap !

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