I’d like to update the test scripts in a a deeply nested postman collection. I’ve had a look at postman-collection to see if it can help me, but all of the methods seems to start at the deepest level then search into each parent. I need to search the entire collection down through all the folders.
I’d first need to look for the name of the request, then access it’s event array. and it can be at any level in the nesting.
Any advice appreciated. I’m thinking I’m going to have to write some kind of recursive loop or something to deeply traverse objects and arrays?
E.G:
{
"info": {
"_postman_id": "7ecc5398-9647-423a-ad92-51e181f2f293",
"name": "Deep Collection",
"description": "Search Deep Collections.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "parent 3",
"item": [
{
"name": "level 2 event",
"event": [
{
"listen": "test",
"script": {
"id": "3d43d2c3-361b-4f68-944c-d9b2e4a6be78",
"exec": [
"// I need to access ths test",
"console.log('Please help me access this test')"
],
"type": "text/javascript"
}
}
],
"request": {},
"response": []
}
{
"name": "parent 2",
"item": [
{
"name": "parent 1",
"item": [
{
"name": "sibling 1",
"request": {},
"response": []
},
{
"name": "sibling 2",
"event": [
{
"listen": "test",
"script": {
"id": "3d43d2c3-361b-4f68-944c-d9b2e4a6be78",
"exec": [
"// I need to access ths test",
"console.log('Please help me access this test')"
],
"type": "text/javascript"
}
}
],
"request": {},
"response": []
}
],
"_postman_isSubFolder": true
}
],
"_postman_isSubFolder": true
}
]
}
]
}