Hello.
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")
.feed(csvFeeder)
.exec(http("Test POST request")
.post(uri)
.header("Content-type", "application/json")
.body(StringBody("{\"id\":\"$id\"}"))
.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…