Import from Postman

You can easily create an API test in mabl by importing an existing Postman Collection (JSON file) that contains a set of API requests and respective JavaScript code available within the Pre-request and Tests sections of requests.

Example of a Postman Collection.Example of a Postman Collection.

Example of a Postman Collection.

Using Postman, click on the More actions (...) menu for a Collection that you would like to import to mabl and select Export.

Exporting a Postman CollectionExporting a Postman Collection

Exporting a Postman Collection

🚧

Collection size limits

Please note that API tests cannot exceed 1MB in size. We recommend using caution with large JavaScript pre-request scripts.

Postman will ask you which collection format you would like to save the exported file in. You can simply proceed with the export without changing the default setting.

Next, open the mabl desktop app, click the New test button in the left sidebar, and select to create an API test.

Choosing what test type to create in mabl.Choosing what test type to create in mabl.

Choosing what test type to create in mabl.

Fill out the test creation form and click on Create test. Note that you may need to configure a base API URL for your mabl environment, if you haven't done so already.

Once you complete the test creation form, you will be presented with an API test editor from where you can import the already exported Postman Collection file.

Importing Postman Collection into mabl to create a mabl API test.Importing Postman Collection into mabl to create a mabl API test.

Importing Postman Collection into mabl to create a mabl API test.

Once you import a Postman Collection, you will see the API requests from Postman have been converted to mabl test steps that you can review.

Example of a mabl API test imported from Postman,Example of a mabl API test imported from Postman,

Example of a mabl API test imported from Postman,

Working with variables

Postman users will often make use of variables to store and reuse dynamic values with the request body, pre-request and test scripts. For example, you will typically use an environment variable such as HOST_URL to define the base URL for each environment that the API request will need to run against.

We recommend that you modify your Postman Collections to use an environment variable named api.url that defines the host URL (e.g. api.mabl.com; api-dev.mabl.com).

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.

Any Postman variables defined at the Collection level will be imported into mabl. To see such variables in Postman, click to Edit the Collection from its View more actions menu and go to the Variables tab.

Example of Postman variables defined at the collection level.Example of Postman variables defined at the collection level.

Example of Postman variables defined at the collection level.

📘

Variable notation

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

All in all, there are five different variable types in Postman that you need to be mindful of when importing an existing Collection to mabl. The following graphic provides an overview of how Postman variables map to variables in mabl. Though, the specifics are more intricate than that.

Variables mapping between Postman and mabl.Variables mapping between Postman and mabl.

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. Note that mabl environments have 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 environment so that it is easier to import/export collections between mabl and Postman.
  • 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.

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.


Did this page help you?