Reputation: 762
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. An example of the body of my request looks as follows:
{ "id" : "123" }
. So, instead of "123"
, I need to use a value from a 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"}
How can I retrieve a value from a feeder and paste it into a body string request?
Upvotes: 1
Views: 2882
Reputation: 762
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
of gatling-charts-highcharts
, gatling-core
& gatling-http
and gatling-maven-plugin
was 3.0.0
. Now I switched to 2.3.1
for gatling-*
dependencies and used 2.2.4
for maven plugin. Now it works.
Upvotes: 0