Please Note: Unfortunately, Team Members that are already subscribed to the environment will NOT have their environments updated. Theyâll have to delete/re-subscribe to environment until the Postman team make this feature possible.
This tutorial is to update a shared environment thatâs been used in your CI. (TeamCity, Jenkins etc.)
Hi,
This was a question that was asked quite a bit in the Postman Slack and it was something that I always found painful - âHow do I edit shared environments/environment variables with my team?â
Unfortunately this isnât supported through the UIâŠyet!
Please +1 the Feature Requests int the Postman Git to show the Postman Team this is something you want
So, is there no way to do this at all through Postman?
Yes, itâs a little cumbersome but it works for me with my shared environments in TeamCity and other Postman Users have confirmed it working.
Get to it already, how do I do this?
OK! Letâs assume we have envionment shared with a team.
Using the Postman PRO API, use the GET All Environments request (youâll need to use your Postman Pro API Key which is unique to you)
GET https://api.getpostman.com/environments
Remember to use the Postman Pro API Key as a Header.
In the above request youâll see all your environments, some shared - some not shared.
Environments that are shared have â.templateâ. in the ânameâ field.
Take note of the value of the âuidâ field.
In the GET Single Environment request pass in the âuidâ as a path parameter
GET https://api.getpostman.com/environments/{{environmentUID}}
Copy the entire response body returned.
Using the PUT Edit Environment request, paste the copied response into the Request Body as raw JSON.
PUT https://api.getpostman.com/environments/{{environmentUID}}
Make sure you select JSON(application/json) from the dropdown above the body.
In the request body, edit/delete/add objects inside the âvaluesâ array.
Each object will be an environment variable:
{
"environment": {
"id": "26cce2d3-2d24-2efe-c168-7312ca87f69c",
"name": "KATA ENV.template",
"values": [
{
"key": "exampleURL",
"value": "https://www.google.com",
"type": "text",
"enabled": true
},
{
"key": "myNewVariable",
"value": "someTextGoesHere",
"type": "text",
"enabled": true
}
]
}
}
Make sure not to change the value of the âidâ field.
If you submit the request you should get a 200 response code and the shared environment should be successfully updated
In this case, in my shared environment âKATA ENVâ, I added a new environment variable named âmyNewVariableâ which has a value of âsomeTextGoesHereâ
Assuming thereâs a Newman test collection in our CI (In my case, TeamCity) thatâs using this shared environment, the shared collection will now have the updated values/variables.
Hopefully thereâs some value in this for you guys until this feature is properly supported through the UI.
Feel free to like this post so other users find it