TIP: Anaplan API with Postman

Options

Doing some work with the Anaplan API recently I found myself annoyed with having to copy/paste the tokenValue you need for each subsequent command after authenticating via https://auth.anaplan.com/token/authenticate.

Below are some tips I found on how to automate it:

 

  • Create yourself a Postman Environment and store your username and password in local variables.
  • I name my variables with a lowercase v at the beginning e.g. vUsername and vPassword
  • You will then be able to use variables in your URLs and Headers by typing {{vUsername}}
  • Create another variable vTokenValue in your environment that will then store the result after you authenticate
  • Create a POST request to https://auth.anaplan.com/token/authenticate using your {{vUsername}} and {{vPassword}} in authentication
  • KEY PART

    Then put the following code into the Tests tab 

    pm.environment.set("vTokenValue", pm.response.json().tokenInfo.tokenValue);
    This will set your Environment vTokenValue with the value return from the API call
    jwakefield_1-1615285624073.png

     

  • Once run you can then check the value is populated in your environment 
  • Now when you do other API calls you just need to add a Header as per below

jwakefield_0-1615285502650.png

 

 
 

Answers