Accessing Request names in scenarios using feeder


I have requests written in following format. BaseClass extends Simulation class and contains headers.

object NewAPIs extends BaseClass {

val request1: ChainBuilder = exec(http("POST - api/v1/analysis”)



.body(StringBody(string = “”"{“startDate”:"${startDate}" ,“endDate”:"${endDate}"}"""))


val request2: ChainBuilder = exec(http("POST - api/v1/analysis2”)



.body(StringBody(string = “”"{“startDate”:"${startDate}" ,“endDate”:"${endDate}"}"""))



I want to access these requests in scenario using a csv feeder. It gives error: “ Can’t cast value NewAPIs.request1 of type class java.lang.String into class io.gatling.core.session.Session”

CSV file format :





Format of scenarios:

val records: Seq[Map[String, Any]] = csv(records.csv).readRecords

val scenario1 = scenario(“scenario1”)

.foreach(records, “record”) {





Is there a way to execute requests in this manner?

No that’s not possible.

What you could do is route on request1 or request2 with a doSwitch.

Thanks Stéphane. Actually, I have a lot of distinct requests in the CSV, and not just two. That was just for example.

That doesn’t change anything. If you want to keep your current way of coding each request, you need a switch to pick the desired one.
Otherwise, use a generic request and make the url a feeder field.