Say I have two environments (test and production) with two different URLs. I also have two services (serviceA and serviceB) that needs different header values. I could deal with this with four environments in Postman:
Here I have duplication of both the URLs and the headers. As I add another url, I need six environments in total:
And as I add another service which requires a changed header value, I need another 3:
How can I avoid this? It would be great if I could choose multiple environments as active. Then I could place a checkmark next to "staging" and "serviceC" for example.
Sharing an environment To share an environment, click the gear icon in the upper right corner of the Postman app and select “Manage Environments”. In the Manage Environments tab, click the Duplicate Environment icon next to the environment you want to share.
In the top right corner of Postman, click the environment selector and select Manage environments.
For a solution specific to Paw:
Paw makes has the concept of environment domains, which allows for easier control on your environment values. Basically an environment domain can have multiple environments, which are representations of the same environment value.
In your case, you could have 3 environments domains (serviceA, serviceB, serviceC), for which you would have 3 environments (test, staging, production)
In general, this allows for a lot of flexibility, as multiple environment domains can be used together in a single request. For instance, one could imagine a Server
environment domain with different environments (us-east-1
, us-west
, ...), which could combine with, say a Version
environment domain (v1.0
, v1.1
, v2.0
, etc.), and combine them into a single request to check whether version 2.0 works on us-east-1, and so on.
For a solution specific to Postman:
You can use some {{}}
intricacies to supercharge some environments.
Environment variables can refer to each other:
Now, when you refer to the environment variable {{some-important-header}}
somewhere, it will actually refer to the {{{{mode}}-some-important-header}}
, which in this case is {{test-some-important-header}}
, or -1
. Every time you want to change mode, you have to change the environment variable value mode
to the correct value, like production
, or staging
.
It's not cleanest solution, but it avoids creating a bunch of environments due to coupling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With