# Accessing Request names in scenarios using feeder

**URL:** <https://community.gatling.io/t/accessing-request-names-in-scenarios-using-feeder/5942>\
**Category:** Gatling (Open-Source)\
**Created:** [December 21, 2020, 10:53am UTC](https://community.gatling.io/t/accessing-request-names-in-scenarios-using-feeder/5942 "2020-12-21T10:53:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shruti\_Lakra](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Shruti\_Lakra](https://community.gatling.io/u/Shruti_Lakra)\
**Post date:** [December 21, 2020, 10:53am UTC](https://community.gatling.io/t/accessing-request-names-in-scenarios-using-feeder/5942/1 "2020-12-21T10:53:06Z")

</div>

Hi,

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”** )

.post( **“api/v1/analysis”** )

.headers(_headers\_1_)

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

.check(_status_.is(200)))

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

.post( **"api/v1/analysis2”** )

.headers(_headers\_1_)

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

.check(_status_.is(200)))

}

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 :

API,Start,End

NewAPIs.request1,2020/12/01,2020/12/05

NewAPIs.request2,2020/12/02,2020/12/09

NewAPIs.request1,2020/12/03,2020/12/10

Format of scenarios:

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

**val** _scenario1_ = scenario( **“scenario1”** )

.foreach(_records_, **“record”** ) {

exec(flattenMapIntoAttributes( **"${record}"** ))

.exec(AuthenticateApis._authenticateApi2_)

.exec( **"${API}"** )

}

Is there a way to execute requests in this manner?

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [December 21, 2020, 12:18pm UTC](https://community.gatling.io/t/accessing-request-names-in-scenarios-using-feeder/5942/2 "2020-12-21T12:18:57Z")

</div>

No that’s not possible.

What you could do is route on _request1 or_ _request2 with a [doSwitch](https://gatling.io/docs/current/general/scenario/#doswitch)._

---

<div class="post-metadata">

**Author:** ![Shruti\_Lakra](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Shruti\_Lakra](https://community.gatling.io/u/Shruti_Lakra)\
**Post date:** [December 22, 2020, 4:57am UTC](https://community.gatling.io/t/accessing-request-names-in-scenarios-using-feeder/5942/3 "2020-12-22T04:57:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [December 22, 2020, 6:29am UTC](https://community.gatling.io/t/accessing-request-names-in-scenarios-using-feeder/5942/4 "2020-12-22T06:29:26Z")

</div>

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.
