# session variable as formParam

**URL:** <https://community.gatling.io/t/session-variable-as-formparam/2564>\
**Category:** Gatling (Open-Source)\
**Created:** [September 28, 2015, 1:02pm UTC](https://community.gatling.io/t/session-variable-as-formparam/2564 "2015-09-28T13:02:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukas\_lang](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@lukas\_lang](https://community.gatling.io/u/lukas_lang)\
**Post date:** [September 28, 2015, 1:02pm UTC](https://community.gatling.io/t/session-variable-as-formparam/2564/1 "2015-09-28T13:02:08Z")

</div>

Hi, i have a question about how to use session variable, as formParam.

i have string variable like this:

`  
Questions[0].AnswerViewModel.Answers[0].QuestionAnswerId=59115&Questions[0].AnswerViewModel.Answers[1].QuestionAnswerId=59116&Questions[0].AnswerViewModel.Answers[0].IsAnswered=false&Questions[0].AnswerViewModel.Answers[1].IsAnswered=true

`

which is created in requests before and has variable number of “Answers[i]” ( Answers[0],Answers[1],…).

Well my question is, how can i use this string in formParam?

from session log:  
FORM\_PARAM\_Z\_FUNKCIE → Questions[0].AnswerViewModel.Answers[0].QuestionAnswerId=59115&Questions[0].AnswerViewModel.Answers[1].QuestionAnswerId=59116&Questions[0].AnswerViewModel.Answers[0].IsAnswered=false&Questions[0].AnswerViewModel.Answers[1].IsAnswered=true

and i want to use something like:  
.formParam("${FORM\_PARAM\_Z\_FUNKCIE}").

is there any way to parse this string into .post param?

I am using gatling version 2.1.7

Thanks for any reply. 🙂

Lukas

---

<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:** [September 29, 2015, 2:48am UTC](https://community.gatling.io/t/session-variable-as-formparam/2564/2 "2015-09-29T02:48:43Z")

</div>

Have you tried this - [http://gatling.io/docs/2.1.7/http/http\_request.html?highlight=stringbody#request-body](http://gatling.io/docs/2.1.7/http/http_request.html?highlight=stringbody#request-body)

---

<div class="post-metadata">

**Author:** ![lukas\_lang](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@lukas\_lang](https://community.gatling.io/u/lukas_lang)\
**Post date:** [September 29, 2015, 7:26am UTC](https://community.gatling.io/t/session-variable-as-formparam/2564/3 "2015-09-29T07:26:27Z")

</div>

I was trying it before, but with no luck.  
Today i tried again, and find out, it wasnt working before, because i used both .formParam() and also .body(StringBody).  
So i used only .body and it worked!

Thanks for idea 🙂

Lukas

Dňa utorok, 29. septembra 2015 4:48:43 UTC+2 Abhinav Gogna napísal(-a):

---

<div class="post-metadata">

**Author:** ![Manohari](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Manohari](https://community.gatling.io/u/Manohari)\
**Post date:** [July 26, 2016, 9:24am UTC](https://community.gatling.io/t/session-variable-as-formparam/2564/4 "2016-07-26T09:24:59Z")

</div>

Can you please send the sample code how the above one works, iam facing the same issue,It will be helpful if send the code

---

<div class="post-metadata">

**Author:** ![lukas\_lang](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@lukas\_lang](https://community.gatling.io/u/lukas_lang)\
**Post date:** [July 26, 2016, 9:55am UTC](https://community.gatling.io/t/session-variable-as-formparam/2564/5 "2016-07-26T09:55:32Z")

</div>

Hi, i just didnt use .formParam at all. Use .body(StringBody) for example:  
`.post("/login") .formParam("login","user1") .formParam("id","12345")`

is same as:  
`.post("/login") .body(StringBody("login=user1&id=12345"))`  
and this way worked for me, even when i used session variable.

As mentioned before by Abjinav, also check documentation [http://gatling.io/docs/2.1.7/http/http\_request.html?highlight=stringbody#request-body](http://gatling.io/docs/2.1.7/http/http_request.html?highlight=stringbody#request-body)

– skryť citovaný text –

Dňa utorok, 26. júla 2016 11:25:00 UTC+2 Manohari napísal(-a):

---

<div class="post-metadata">

**Author:** ![Manohari](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Manohari](https://community.gatling.io/u/Manohari)\
**Post date:** [July 26, 2016, 11:15am UTC](https://community.gatling.io/t/session-variable-as-formparam/2564/6 "2016-07-26T11:15:11Z")

</div>

Thanks for the reply Lukas, i tried the same and no luck for me…

Thanks
