Environment Variable with several values

So, this is something that I’m wondering if it is possible and if so, how to approach it.

So, my idea is that I want to set a variable that would have several different values, like an array I suppose? e.g. Apple, Grape, Cherry , Berry, Orange

And then I’m thinking of a script that would get on of the above options and set it in a new variable, that would then be used in the body.

After which I’m wondering whether to run it in a loop, until all values have been used - same api request, just with new value for that variable or maybe I should just run the collection multiple times and be happy with the results?

Anyway, this is more of a question if it is doable.

edit:
To be more precise of what I’m looking to do, it’s basically like _.random, however for a predefined variable - having 5 strings/numbers that would be randomly picked for each run of the api/collection.

Of course you can store and manipulate arrays in any way you want.

Yes, it is doable. Here is something to get you started:

Feel free to ask additional questions.

1 Like

Yes, thank you. This is actually quite helpful.
However I’m looking to do it without using .setNextRequest.

What I’m looking to do and will hopefully have it done within an hour of writing this, I will make a variable with different data, which I’m hoping to extract by targetting data from the array with an index, as I have the array with 4 values , so I’m going to try to create an index with ._random(0, 3), which should also allow me to test it in the next request by using the same index random value.

Anyway, thanks again

You cannot change where Postman goes next, without using setNextRequest.

I would be very interested to see how your solution looks like.

Hey, what I meant to do is use Collection Runner with more than one iteration, so for each new iteration that data would be different as most of my variables are array lists and I’m using ._random to get a different (or the same value if the number is the same) value from the arrays on each run.