# Dynamically inject session values to feeder data

**URL:** <https://community.gatling.io/t/dynamically-inject-session-values-to-feeder-data/2289>\
**Category:** Gatling (Open-Source)\
**Created:** [May 14, 2015, 10:12am UTC](https://community.gatling.io/t/dynamically-inject-session-values-to-feeder-data/2289 "2015-05-14T10:12:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenny](https://avatars.discourse-cdn.com/v4/letter/k/90db22/32.png) [@Kenny](https://community.gatling.io/u/Kenny)\
**Post date:** [May 14, 2015, 10:12am UTC](https://community.gatling.io/t/dynamically-inject-session-values-to-feeder-data/2289/1 "2015-05-14T10:12:25Z")

</div>

Hi,

I was trying to read all the different post in the google group for related information, but could not find similar solution.

basically i have designed a chainbuilder of several execution. I like to ask if we can pass in session value into a placeholder in feeder ?

i.e.  
Feeder file:

- **JSON\_string**  
“parm”: “1”, “value”: “${mySessionValue}”

Scenario Code:  
exec(  
http(“Check\_Status”)  
.get("/test")  
.check(jsonPath("$.testValue").exists.saveAs(“mySessionValue”))  
)  
exec(http(“Check\_status\_2”)  
.post("/users/${id}/patternJobs/cluster")  
.body("""{${ **JSON\_string** }}""").asJSON  
)

How can i do this?

Gatling Version: 2.0.0

---

<div class="post-metadata">

**Author:** ![Abhinav\_Gogna](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Abhinav\_Gogna](https://community.gatling.io/u/Abhinav_Gogna)\
**Post date:** [May 14, 2015, 1:26pm UTC](https://community.gatling.io/t/dynamically-inject-session-values-to-feeder-data/2289/2 "2015-05-14T13:26:46Z")

</div>

I dont think that will work.

As a workaround, use the feeder without “${mySessionValue}” and right before “Check\_status\_2” concatenate string in a session function

Something like  
`

exec(  
http(“Check\_Status”)  
.get("/test")  
.check(jsonPath("$.testValue")  
.exists.saveAs(“mySessionValue”))  
)  
.exec{session =\>  
val jsonString\_1 = session(“JSON\_string”).as[String] + session("`mySessionValue").as[String]`

exec(http(“Check\_status\_2”)  
.post("/users/${id}/patternJobs/cluster")  
.body("""{${ **JSON\_string** }}""").asJSON  
)

`

---

<div class="post-metadata">

**Author:** ![Abhinav\_Gogna](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Abhinav\_Gogna](https://community.gatling.io/u/Abhinav_Gogna)\
**Post date:** [May 14, 2015, 1:29pm UTC](https://community.gatling.io/t/dynamically-inject-session-values-to-feeder-data/2289/3 "2015-05-14T13:29:36Z")

</div>

Did an accidental post without the entire code.

`exec(`  
http(“Check\_Status”)  
.get("/test")  
.check(jsonPath("$.testValue")  
.exists.saveAs(“mySessionValue”))  
)  
.exec{session =\>  
val jsonString\_1 = session(“JSON\_string”).as[String] + session("`mySessionValue").as[String]`  
`session.set("jsonString1", jsonString1)`  
`}`  
.exec(http(“Check\_status\_2”)  
.post("/users/${id}/patternJobs/cluster")  
.body("""${`jsonString1`}""").asJSON  
)  
``

` `  
`

`

---

<div class="post-metadata">

**Author:** ![Kenny](https://avatars.discourse-cdn.com/v4/letter/k/90db22/32.png) [@Kenny](https://community.gatling.io/u/Kenny)\
**Post date:** [May 14, 2015, 3:18pm UTC](https://community.gatling.io/t/dynamically-inject-session-values-to-feeder-data/2289/4 "2015-05-14T15:18:31Z")

</div>

Yup, looks like there isn’t other solutions.

Thanks.
