I have a Postman collection running with No issues, However, I am attempting to refactor it for improved reusability. In light of this, I am seeking advice on the optimal approach.
My particular use case involves two collections. The first, Connector, contains two requests - Delete Connector (Method: DELETE) and Create New Connector (Method: POST). The second collection, API E2E flow, has two requests - GET call and POST call, with the latter being dependent on the successful execution of requests 1.1 and 1.2 in the Connector collection.
In order to streamline my testing process, I am seeking advice on the most efficient method to execute requests 1.1 and 1.2 as pre-script from 2nd collection.
One approach I have tried is but didn’t like that much"…"
— PRE-SCRIPT
pm.sendRequest({
url: 'https://api.getpostman.com/collections/21abd494-403e-486d-9b41-4f68837218d3',
header: {
'X-Api-Key': '*** KEY ***',
'Content-Type': 'application/json'
},
body: {
mode: 'raw',
raw: JSON.stringify({
"collection": {
"info": {
"_postman_id": "21abd494-403e-486d-9b41-4f68837218d3"
}
},
"environment": {
"values": []
}
})
}
}, function (err, res) {
if (err) {
console.error(err);
} else {
console.log("RESPONSE is :" +res.text());
var runUrl = '*** Delete Connector (Method: DELETE) *** ';
pm.sendRequest({
url: runUrl,
method: 'DELETE',
header: {
'X-Api-Key': '*** KEY ***'
}
}, function (err, res) {
if (err) {
console.error(err);
} else {
console.log(res.text());
}
});
}
});