Lets say I have a collection that contains a single POST request that contains a single piece of data in the body. his requires no authentication of any kind
PUT name httP://whatever/api/…
{
name: “nameOne”
}
This works fine for adding names one at a time but I have 1000 names to add.
In this case I can put them in a file with the heading myName, change my body to
{
name: “{{myName}}”
}
and use a collection runner to run through the file and add all my names. This works just fine.
So now I want to change the request so that if for any reason there is an error I can make it stop the runner.
I need to do this in a script somewhere, but where and how?
I’m not interested in setNextRequest(null) this would only exit me out of the current iteration if I had multiple steps. The rest of the iterations would still run.
I’m not really interested in setting a variable and testing that in the pre-request script the setting setNextRequest(null) cos I still have to run though all 1000 iterations.
Same with throw new Error(‘halt’);
What I’d like to know is what function, script, variable anything really can utilise in a script to do the exact same thing as the Stop Run button?
If I have an error on record 50 I don’t want to have to iterate through another 950 records before it gets to the end of the file doing nothing but avoiding the request. I just want it to stop.