Variables in Postman imports

How to work with variables in API tests imported from Postman

Postman users often make use of variables to store and reuse dynamic values with the request body, pre-request and test scripts.

📘

Variable notation

You can use the Postman variable notation {{variableName}} when working with API test variables in mabl.

Postman variable types

There are five different variable types in Postman that you need to be mindful of when importing an existing Collection to mabl. This graphic provides an overview of how Postman variables map to variables in mabl:

20972097

Variables mapping between Postman and mabl

Given this variables mapping, you may need to take the following actions:

  • Environment variables in Postman will need to be defined for each environment in mabl.
  • Global variables in Postman will need to be defined either at environment level in mabl or added to the Postman Collection that is being exported.
  • Postman Collection-level variables will be automatically imported and associated with the respective mabl API test. You will see them on the test details page under the data-driven variables section.
  • If you use Postman data-level variables, such as pm.iterationData.get("variable_name"), within your requests, you will need to create a DataTable in mabl and associate it with the respective API test. When the test runs, mabl will assign values to the pm.iterationData variables based on matching variables names from the DataTable.
  • Any Postman local variables will be considered test-generated variables in mabl and as such will be passed to the following API requests as well as shared with other tests within the plan, if sharing variables is enabled for the test.

📘

Importing CSV or a JSON file with test data

Test data in CSV or JSON files needs to be converted to a mabl datatable in order to be used with imported Postman Collections in mabl. You can easily create a mabl datatable from a CSV file import, however JSON file format is not supported at the moment.

Importing a base URL

Mabl applications use a base API URL that is assigned to a system-level variable called api.url. We recommend you use the same api.url variable name for the base URL within your Postman collection so that it is easier to import/export collections between mabl and Postman.

15541554

That way, when you import the Postman collection into mabl, the URL for API requests will be automatically composed based on the configured api.url values for the mabl environments.

Postman dynamic variables

Postman also has the notion of dynamic variables that can help you generate dummy data for your API requests. Such dynamic variables will work as expected with with mabl.

Postman folders

Postman allows you to organize your testing using folders. Unfortunately, we do not support importing collections with folders at this time.