1
votes
{
  "aggregateResults": true,
  "targetTimeSeries": "finalForecast",
  "filter": {
    "id": "f3456789sdsd779sds4488"
  }
}

This the content of my JSON file, I want to change the value of id before sending this JSON as body in a POST request for my gatling script.

Since this is small JSON, currently I am passing it to StringBody and replacing the dynamic part to achieve this successfully but this method will not be useful for long JSON responses with which I have to deal with in future.

Please guide.

1

1 Answers

3
votes

You can embed gatling expressions in your JSON.

Assuming your desired id is in a session variable called "id" you could have your file like this:

{
  "aggregateResults": true,
  "targetTimeSeries": "finalForecast",
  "filter": {
    "id": "${id}"
  }
}

And then use an ELFileBody instead of a RawFileBody to supply the file.