Can I do scala code inside of body( )

I need to create a scenario where I use the data (as JSON) returned in one request, store it in session, and then reference it (with a little help from Scala) in another request.

What I do not want to do is put an exec( session => … ) between the two requests. Instead, I want to have a check( …saveAs ) in one, and then reference and apply logic to what is saved in the other.

In other words, I would like to do this:

http( “my request” )
.post( url )
.body( session => {
// compose the body string and return it

Does Gatling 2 support that kind of thing, and if so, is that the syntax or is there some other way I need to do it?

That’s exactly what’s described at the end of this section:

FYI: I looked at that section of the docs several times, and had no idea that it was the answer to my question.

And after you said something, I had to do trial and error to figure out how to use it. I suggest that the docs pertaining to that particular feature need a little more details added. :slight_smile:

If you have some suggestions about how to improve the documentation, the best thing is to contribute and send a Pull Request :slight_smile: