Hello everyone,
My apologies, I am not a Developer, however I have been placed with a task with creating an automatic way to obtain values found thru the Meraki API.
The main goal is to obtain the "Subnet" for every NetworkId that belongs to VLAN 1, then create a .csv file so I can import it into a monitoring tool called DCRUM.
So I thought I would use PostMan to achieve this. I am able to set the Environmental Variables for the first step.
https://api.meraki.com/api/v0/organizations/{{organizationID}}/networks/
Below is the Test Script I am using, it successfully populates the Environmental Variables (NetworkName, networkNAMEs, NetworkID, and NetworkIDs.
var jsonData = JSON.parse(responseBody);
var schema = {
"id": {
"name" :{
}
}
};
var networkNAMEs = [];
var networkIDs = [];
jsonData.forEach(function(network) {
var testTitle = network.name + " , " + network.id + " conforms to schema";
tests[testTitle] = tv4.validate(network, schema);
networkNAMEs.push(network.name);
networkIDs.push(network.id);
});
postman.setEnvironmentVariable("NetworkName", networkNAMEs.shift());
postman.setEnvironmentVariable("networkNAMEs", JSON.stringify(networkNAMEs));
postman.setEnvironmentVariable("NetworkId", networkIDs.shift());
postman.setEnvironmentVariable("NetworkIDs", JSON.stringify(networkIDs));
The second Request I need to run the following URL in a loop, each time updating the NetworkId variable within the URL with the next NetworkId in the NetworkIDs EnvironmentVariables.
https://api.meraki.com/api/v0/networks/{{NetworkId}}/vlans/1
However, my Test Results all fail with the below error:
FAILStatus code is 200 | AssertionError: expected response to have status code 200 but got 404
The Test Script I am using is:
var networkIDs = [];
networkIDs = JSON.parse(postman.getEnvironmentVariable("NetworkIDs"));
console.log(networkIDs);
for (var i = 0; i < networkIDs.length; i++) {
postman.setEnvironmentVariable("NetworkId", networkIDs[i]);
postman.setNextRequest();
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
}
What I really need to know is, am I going about this the right way? Should I be using a different tool?
If not, the outcome I need is to be able have the Test Results contain the Networkname and Subnet for each iteration and save the results in a .csv, or any file that I can convert later to a .csv.
I hope this is enough details for everyone, please just let me know if I'm just a little too slow to tackle something like this. : )
Thanks for all the help,
Tom