I have just recently Updated my Postman Version to 8.0.3 and got the “New UI”
I the previous versions the there was a “Count” of the number of requests that were contained within a Collection that showed up adjacent to the collection name.
I’m not seeing this count any more.
Did this get Moved?
If so where too?
Deprecated?
I hope not as we used this as part of our Management of close to 7000 requests in 29 collections that we run on a daily basis.
if this is the case is there an “easy” way to get a count of the number of requests in a collection without actually “Counting” them one by one. We use a multi level request set structure that would make this very tedious and time consuming.
This was removed as part of the major UI update that came with the V8 release, we are listening to this feedback and the team is working on adding this information back into the new UI.
Depending upon your needs, one way that you could to this would be to utilise the Postman API itself, which (when authenticated) allows you to retrieve data about your collections.
If you perform a Single Collection request (specifying the ID of your collection) then you can add code such as the below into its Tests tab. This will recursively loop through all of the items in the collection (including subfolders) and extract a total count of the requests within the folder.
function countRequests(obj) {
for (let item in obj) {
if(obj[item].hasOwnProperty("request")) {
requestCount += 1;
} else {
countRequests(obj[item].item);
}
}
}
var requestCount = 0;
countRequests(pm.response.json().collection.item);
console.log("Collection contains " + requestCount + " requests");
When I run this script against one of my collections, I see the correct number output in the console:
Can you check the Body tab of the response, to ensure you have successfully loaded your collection data?
If the data failed to load (such as below, where I had not successfully authenticated with the endpoint) then the test script would fail, because it cannot find the collections data in the response.
If you have successfully retrieved the details of a single collection, the response will begin like the below, and the script should complete successfully:
Your response is returning “collections” rather than “collection” - this indicates that it is trying to return all of your collections. (The list of all collections does not include details of the individual requests within.)
You should ensure that your collection ID is being set correctly in the request URL (either by setting it within a variable, or by hardcoding in the URL). This should ensure that you get “collection” back in the response, which will contain full details of all the sub-requests.