Collection variable from Postman response to update environment

Kenneth
Getting noticed

Collection variable from Postman response to update environment

Anyone out there have done some updates to Postman environments. I'm looking into creating org with Postman, then pull the {id} from the response to update the {organizationId} in the environement and the run create network and pull {networkId} to update network settings.

 

has anyone an example test code for this, I'm struggeling to update the environment variable.

2 Replies 2
Inderdeep
Kind of a big deal
Kind of a big deal

@Kenneth : Check this out 

https://www.postman.com/meraki-api?tab=collections

https://github.com/dexterlabora/Meraki-Dashboard-API-Postman-Collection 

 

Regards/Inder
Cisco IT Blogs awarded in 2020 & 2021
www.thenetworkdna.com
ShawnHu
Meraki Employee
Meraki Employee

@Kenneth  You can write test scripts within postman to achieve this.

https://learning.postman.com/docs/writing-scripts/test-scripts/ 

 

Here is an example to iterate the organization list from getOrganizations request and set target org id to an environment variable.  (of course, you need an environment and associate it with your requests)

 

const jsonData = JSON.parse(responseBody);
for (let i = 0; i < jsonData.length; i++ ){
  if (jsonData[i]['name'] === "postman-test"){
  pm.environment.set("organizationId", jsonData[i]['id']);
  }
}
Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.