How to stub iteration data when not using CollectionRunner

Hey.

I am trying to test our my collection in Postman prior to using Collection Runner.

When I change my scripts to use pm.iterationData, everything works fine in the Runner. However, if I want to run a one off request in my collection without using the runner (and not loading the associated data file) I get null values for anything defined in the data file (pm.iterationData.get(…)).

What is the best way to solve this? I really don’t want to add a pre-request script for each request to ensure that values are defined or to do some sort of defaulting.

if you use pm.environment.get,pm.iterationDat.get etc it will retrieve only the specific varaible in that scope. If you want to get an variable irrespective of the scope use.

pm.variables.get("test")

This will return the value of variable with name test in any scope , local,environment,collection. data etc depending up one the precedence.

Meaning if environment and data variable has same name then the value will be from data as precedence is opposite to scope

1 Like

Awesome! Thank you.

I will use pm.variables instead.