Gatling exec with session

I’m posting this the second time now because somehow it disappeared the first time I posted it, so please let me know if this post exists twice now.

Note that this post also has a Stackoverflow version.

I need to make a request in Gatling, in which I’m able to access session items (without the expression language). I need to do this, because I want to inject data into a ByteArrayBody request from a csv feeder. To demonstrate my problem, I have a small example (without the actual need of the session).

The following scenario runs fine:

val scnBase: ScenarioBuilder = scenario("Test scneario").repeat(1){
  exec(http("Http Test test").get(""))

But that one doesn’t (I get the exception There were no requests sent during the simulation, reports won't be generated):

val scnBase: ScenarioBuilder = scenario(“Test scneario”).repeat(1){
exec(session => {
http(“Http Test test”).get(“”)


I run my simulations in IntelliJ (which worked fine so far) and in the following (here minimized) simulation file:

I very well may be wrong, but I think it does not work because the simulation only sees a call using session and no other execs. Just to debug can you try adding any kind of .exec(http(“something”).get(“blah”) and then interact with session? I typically separate interactions with session into their own exec call and have no issues.

You are right, exec(session => session) is meant to be used to manipulate user data, not perform requests.

As http().get() is only a builder and not a function that directly perform a request, its returns something that needs to be pushed to Gatling so that Gatling can perform the request : I.e. exec(http().get())

But how do I inject the data into the ByteArrayBody then? I can’t use EL, as Gatling doesn’t detect it if encoded in EBCDIC (which I need).

I realized that it’s possible to write an expression in the constructor of the ByteArrayBody, which solves my problem. Thanks for your help everybody!