Get a value from a CSV feeder to create a POST request body


I have a pretty simple scenario to get a random value from a CSV file that contains only one column with header id. Then, I want to paste this value into a body of a POST request. The body of my request looks as follows:
{ “id” : “123” }. So, instead of “123”, I need to use a value from CSV file. Here are my feeder and scenario:

val csvFeeder = csv("src/test/resources/ID.csv").random

val scn = scenario("Test POST request")
  .exec(http("Test POST request")
    .header("Content-type", "application/json")
    .check(status is 200, responseTimeInMillis lte 2000)

This example is the closest implementation I managed to make so far. But it doesn’t work as I expect. I can’t paste the value from a feeder into $id that is inside a body(). Currently, Gatling sends the following body: {“id”:"$id"}

Could you please help me and advise how can I paste a feeder value into a POST request body?
This test is my first experience with Gatling and Scala, thus I might not understand and miss some basic things…

Found the solution. The code is right. The issue was in the version of artifact I was using. I used version 3.0.0-RC3 and gatling-maven-plugin was 3.0.0. Not I switched to 2.3.1 for gatling-core and 2.2.4 for maven plugin. Now it works.

No, your code is wrong.


The proper Gatling EL syntax is ${id}.

Yes, that is as well. But before changing the version of dependencies, I tried both $id and ${id} and had no luck.