Feed multiple n-rows from CSV to json payload

alexM
Tue, 20 Sep 2022 21:30:00 +0000
Gatling (Open-Source)

Hi,
I want to load n-rows from the csv file to .json file
Example :
in my CSV I have the Below data with header planetNames:

planetNames
Mercury
VENUS
Earth
Mars
Jupiter
Saturn

in the code

val planetFeeder = csv(“data/DataVolume/planets.csv”).random

private val planetsRequest = exec(_.set(“token”, AccessToken))
.feed(planetFeeder, 2)
.exec(http(“PlanetREquests”)
.post(“example-request”)
.headers(Map(“Accept” → “application/json”, “Content-Type” → “application/json”))
.body(ElFileBody(“System/planetFile.json”))
.check(status.is(200))

Below is body of planetFile.json file :
[#{planetNames}]

When tried to feed multiple rows in my .json file with the above attribute it fails with the below error

00:39:25.049 [ERROR] i.g.h.a.HttpRequestAction - ‘httpRequest-1’ failed to execute: No attribute named ‘planetNames’ is defined

7 posts - 4 participants