Last Updated: February 25, 2016
· jeantil

Extract and reuse a list of identifiers with Gatling

If you are writing a bench for a batch create/read API, you may need to manipulate list of identifiers instead of a single id. Let's see how you can do that with gatling (1.3x-1.4x).

Let's say that we have the following JSON API :

POST /events 
GET  /events/:comma_separated_id_list

Where the post accepts a payload with multiple events and returns them with identifiers when they are created. You want to capture these identifiers and reuse them later to generate the :commaseparatedid_list.

First comes the capture. The naive approach would be to add the following check to the POST call


Unfortunately that would save an ArrayBuffer of values in the idList session variable. With gatling you can't "transform" the captured value when you use it. This snippet won't work:


However you can apply transformations at capture time. Changing your check to


and your call to


further info on checks and transform can be found on the gatling wiki