Feed multiple n-rows from CSV to json payload

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:


in the code

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

private val planetsRequest = exec(_.set(“token”, AccessToken))
.feed(planetFeeder, 2)
.headers(Map(“Accept” → “application/json”, “Content-Type” → “application/json”))

Below is body of planetFile.json file :

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

Looks correct to me, except for the JSON serialization for which you should use jsonStringify(), but that wouldn’t explain the “No attribute” error.
Please provide a full reproducer as a project on Github.

But if i provide as below then it works perfectly.

with .feed(planetFeeder, 2), i believe the session names would be:

  • planetNames1
  • planetNames2
1 Like

Thanks @shade this worked. Thanks for the solution.


OK, this is a typical example as to why we request that you use an up-to-date version of Gatling before opening threads here: How to Ask a Question

The behavior has changed in Gatling 3.8, see Gatling - Migrating from 3.7 to 3.8

  • #4226: The feed override that takes a number of entries now produces arrays instead of translating the keys with an index suffix.


  • with Gatling <= 3.7 => indeed, you have planetNames1 and planetNames2
  • with Gatling >= 3.8 => you have a planetNames array whose entries you can access with #{planetNames(0)} and #{planetNames(1)}, or just directly use the array with #{planetNames}
1 Like

If someone want to see example in Java for this case, please visit:

1 Like