Proactive API performance testing and monitoring are vitally important within web application development. Postman is one of the most popular API testing tools that allows web developers to create collections of calls with input data to an API and check the accuracy of the output data. In this article we will discuss a way to define and use Postman environment variables in Dotcom-Monitor tests.

If you use Postman to test your API services, and you want to automate your tests and continuous monitoring, the Dotcom-Monitor platform provides you with comprehensive solutions and tools to create and run API load tests and monitoring task using Postman Collections. To learn how to set up an API load test using Postman Collections in our load testing solution, LoadView, read our Web API Load Testing with Postman Collection. To learn more about setting up monitoring devices, see our Postman Monitoring (Collection Tasks) with Dotcom-Monitor APIs article.

Postman Variables

Environment variables can be defined by clicking on the eye icon in the upper-right corner of the Postman window (see the Postman learning center website for details). These variables allows developers to store and reuse parameter values in API requests and scripts. If you need to update a variable value, you can do it in one place and the value will be automatically changed throughout your request collections. The environment variables in Postman can be used in the URLs, in the POST parameters, in the JavaScript code, etc. To specify the variable, use the brackets as a variable name placeholder:

{{<variable>}}

Since variables exist separately from request collections in Postman, the variables values are not passed together with a Postman collection upon import to Dotcom-Monitor. Therefore, if you need to import a Postman collection that uses variables to Dotcom-Monitor, you have to redefine the variables values in the Dotcom-Monitor test settings by using the Context Parameters feature.

Defining Context Parameters for Postman Collections in Dotcom-Monitor

To define a value of a Postman environment variable in Dotcom-Monitor, you need to create a context parameter associated with this variable:

  1. On the Task Configuration sidebar, click the actions menu button   and select Manage Context Parameters.
  2. Specify an exact same name of the variable as it appears in the uploaded Postman collection. Otherwise, the variable will be parsed as text.
  3. Specify a value of the variable in the corresponding input field and select Done.

Once the Postman Collection test has been saved, the system will use the provided context parameter’s value in the API request.