You can do it though the API.
Create a get request to https://api.getpostman.com/collections/' + collection_id
, and then in the Test tab where you usually run scripts from, you can use something like this:
var postman_api_key = pm.environment.get("postman_api_key");
var response = pm.response.json();
var collection = response.collection;
var collection_id = request.url.split('/')[4];
function processItem(item){
for (let i = 0; i < item.length; i++) {
if(item[i].request){
if(item[i].request.auth){
var t = {};
t.type = 'inherit';
item[i].request.auth = t;
}
}
if(item[i].item){
item[i].item = processItem(item[i].item);
}
}
return item;
}
collection.item = processItem(collection.item);
var update_collection = {};
update_collection['collection'] = collection;
const postRequest = {
url: 'https://api.getpostman.com/collections/' + collection_id,
method: 'PUT',
header: 'x-api-key:' + postman_api_key,
body: {
mode: 'raw',
raw: JSON.stringify(update_collection)
}
};
pm.sendRequest(postRequest, (error, response) => {
console.log(error ? error : response.json());
});
This probably isn't doing 100% exactly what you want, but it's probably close enough that you get the idea, and can modify it yourself.
Then just execute the dummy request