Passing String data to an interpolation

Hi there, currently I am facing an unexpected behavior where the string interpolation doesn’t work as my expected, here is the code that I am using base on Gatling doc here and here

    session => 
        //This is the data, which returns a String
        val responseString = session.attributes.get("theString").toString().slice(21,28)
        val newKeyVar = session.set("myKey", responseString)
                  "dataField": {"param": "#{newKeyVar}"}

I am expecting that I can take out the String value from variable newKeyVar to pass in the post request below, it seems that the compiler could not find the value of this variable, what could be the wrong input here?

What goes inside #{} is the attribute name, hence myKey .

1 Like

hi @slandelle , thank you for your response, my code now works good.

I notice that your doc doesn’t have an example for this use case, I think it’s a good point to put into doc so that people won’t get the wrong idea there.

Thanks for considering my suggestion.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.