pratiks
10/14/2016 - 5:13 PM

postman_get_set_environment_variables.js


postman.setEnvironmentVariable(variableName, variableValue) ;// Sets an environment variable “variableName”, and assigns the string “variableValue” to it. You must have an environment selected for this method to work. Note: Only strings can be stored. Storing other types of data will result in unexpected behavior.
postman.getEnvironmentVariable(variableName); // Returns the value of an environment variable “variableName”, for use in pre-request & test scripts. You must have an environment selected for this method to work. Note: Only strings can be stored. Storing other types of data will result in unexpected behavior.
postman.setGlobalVariable(variableName, variableValue) // Returns the value of an environment variable “variableName”, for use in pre-request & test scripts. Note: Only strings can be stored. Storing other types of data will result in unexpected behavior.
postman.getGlobalVariable(variableName) // Sets a global variable “variableName”, and assigns the string “variableValue” to it. Note: Only strings can be stored. Storing other types of data will result in unexpected behavior.
postman.clearEnvironmentVariable(variableName) // Clears the environment variable named “variableName”. You must have an environment selected for this method to work.
postman.clearGlobalVariable(variableName) // Clears the global variable named “variableName”.
postman.clearEnvironmentVariables() // Clears all environment variables. You must have an environment selected for this method to work.
postman.clearGlobalVariables() 


// Postman also has a few dynamic variables which you can use in your requests. 
// This is primarily an experiment right now. More functions would be added soon. 
// Note that dynamic variables cannot be used in the Sandbox. You can only use them in the {{..}} format in the request URL / headers / body.

{{$guid}} // Adds a v4 style guid
{{$timestamp}} // Adds the current timestamp.
{{$randomInt}} // Adds a random integer between 0 and 1000