How do I increment the value of a parameter in an http request each time the scenario is run starting with a certain value?

Hey Sorry for the newb question but I am trying to use an http request for an API which has an offset parameter that I would like to start at say 805 and then increase by 1 each time the scenario is run so that it always returns the latest record in the data. I see that I can use a variable in the parameter value field and I see a math module I could possibly use to increase that value by 1 each time, or there is also an incrementer tool.

If I set the variable, then each time it runs it will reset it back to 805. So how do I set the variable to 805 only once?

I tried using the AI helper for the value by entering “Start at 805 and increase by 1 each time the scenario is run” and it gave me the following:

{{if(equals(var.scenario.executionType; “manual”); 805; var.scenario.operationsConsumed + 1)}}

But that doesn’t work. Each time I run the scenario manually, it actually sets the offset to 804. Plus, I want the scenario to run automatically every hour or so.

Thanks

Hi @secretagency

Whenever you set the variable inside the scenario itself, it will start with the hardcoded value every time.

If you want it to be persistent between executions, you need to store it permanently somewhere else.

You can use make’s own Data Store, creating a data structure that only holds a number. Or you can use anything else that can hold a value, like a Google spreadsheet.

Just remember to read the value, increase it by 1 and update it on every run.

@damato

4 Likes

Thanks so much for the quick reply! I’ll try it!

UPDATE: It Worked! THANK YOU @damato !

2 Likes