Would anyone know how to import a list (of IPv4 addresses in this instance) into a postman Pre-request script? So for example - I have a request that is working, but uses a ‘hard-coded’ list of IPs in the Pre-request script - what I’m after idsa way to import this list somehow, maybe an environment variable or an imported list:
var deployments = [];
// Iterate over the range for i (1-4) number of nodes
var nodeIP= ["10.0.1.1","10.0.1.2","10.0.1.3","10.0.2.1","10.0.2.2" ]
for (var x = 0; x < nodeIP.length; x++) {
// Iterate over the range for i (1-30) for the number of deployment
;
// Create deployment object
var deployment = {
"template-name": "SRL_ACL_System_Filter",
"target-data": JSON.stringify(pstmtsrlpayload),
"targets": [
{
"target": "/nsp-equipment:network/network-element[ne-id='"+nodeIP[x]+"']",
"target-identifier-value": "system-filter"
}
],
"deployment-action": "deploy",
"merge": false
};
I have tried things like the following without success:
What will be the data source of the list of IPs? Are you looking to get them from an API, have them in a csv or JSON file, etc? It’ll be helpful to know how this data will be presented to suggest a good way of programmatically “importing” it.
Thanks @gbadebo-bello,
I don’t mind how they are presentecd - CSV, JSON, postman environment variable or something else - that is easy to adapt. So let’s say CSV - that’s the simplest - I have to present this as an easy method to a field community, who won’t want any excessive complexity
What errors did you get when you used an environment variable? Can you share maybe a sample code of how you’re using this with an environment variable. Ideally, that should work for your usecase.