Hi,
I have a collection which contains several requests.
I want to run the collection.
I tried with Run button in postman:
it returns runtime:extensions-request: reuqets url is empty in my first request but i have the url in the first request.
I tried with javascript code:
first exported the collection to collection id
the i used it in my code
var collectionId = âyour_collection_idâ;
var iterations = 1;
var collection = pm.collection.get(collectionId);
if (collection) {
for (var i = 0; i < iterations; i++) {
collection.requests.forEach(function(request) {
pm.sendRequest(request, function(err, response) {
console.log(response);
});
});
}
} else {
console.log(âCollection not foundâ);
}
It returns TypeError: Cannot read properties of undefined (reading âgetâ)
Platform Details:
Postman App: Postman free version without sign in
System version: windows 11
Which will return a JSON representation of that collection.
What is the loop meant to be doing? Iâm guessing you want to potentially loop through each request in the collection. The JSON representation of the collection will not be in the correct format for you to just pass it to pm.sendRequest. You will need to parse the response, target the loop at the correct element in the collection JSON, and then pull out the relevant data that is needed to make a request.
As Danny has mentioned, why canât you just use the collection runner?
Hi,
here is my answer: As Danny has mentioned, why canât you just use the collection runner
I m using postman without sign in, without any account.
In this version when i click on run it says i have to sign in, this is what i donât to do.
So think without an account we cannot run a collection (run all requests in one time, instead of running them one by one)
There is more than just the request that goes into a collection.
If you are using the authorization helpers, then the collection JSON will have auth details.
You have the details in the pre-request script and tests tab. Collection variables, etc.
You canât just take the collection JSON and run it using sendRequest().
The only real way to run or even develop a collection is to sign in.
Iâm assuming you must be using a old version of the client, as you need to sign in to even access the collections in the current versions.
You have the lightweight client for those who donât want to login, but that will only allow you to make individual requests. It wonât allow you to run collections.