session variable as formParam

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. :slight_smile:

Lukas

Have you tried this - http://gatling.io/docs/2.1.7/http/http_request.html?highlight=stringbody#request-body

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 :slight_smile:

Lukas

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

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

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

– skryť citovaný text –

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

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

Thanks