Populating POST body with values from preceding HTTP JSON response

Hello,

I am trying to write a Gatling scenario which after a first HTTP request extracts values from the JSON response and uses those values to populate the POST JSON body of a subsequent HTTP request. The subsequent request should only be made 10% of the times.

I guess I have to use transformResponse for processing the response, saveAs and randomSwitch but I could not find a suitable example. I am also not very familiar with Scala.

If someone has done something similar and has an example to share I’d appreciate it.

Gatling version is 2.1.4

Thank you,

/David

Hi David,

Capture JSON elements with JsonPath checks + saveAs, and then use a template (for example ELFileBody).

Thank you for the hint. I figured it out with the help of templates JsonPath and doIf.

/David