Settings and code to make the most of Postman.
- Create all the environments you need. These can be named anything you see fit
- These environments only need two variables
- Add the 'URL' variable to the url of all your requests
- Create a top level collection to hold all of the APIs you want to use auto-authentication
- Edit the collection and add the following variables in the
Variables
tab. Note the names matter here since they are referenced in the script. Also make sure that theCurrent Value
column is filled in since this is what the script uses. - Copy 'authentication-pre-request.js' and paste it in the 'Pre-request Scripts' tab
- Make sure 'Authorization' for all of your requests are set to 'No Auth'. The pre-request script will handle this setting. The easiest way to do this is to set the top level collection to 'No Auth' and leave all others at their default value of 'Inherit auth from parent'.
- Make a request! Check the Postman console if errors occur.
There are multiple ways to handle version numbers in postman but using global variables looks to be the simplest.
You can access global variables by clicking the 'eye' symbol in the top right of the postman window.
Click the Edit
link in the Globals
section and add a version
variable.
Then add the version
variable in place of the version number.
You can edit the version number on the fly by hitting the eye
button again and hovering over the Current Value
which will show an edit symbol.