Importing Postman Collections, Variables, and Environments
If you have a Postman API Collection, you can import it directly into API Testing on Sauce Labs and use it to generate tests.
What You'll Need
- A Sauce Labs account (Log in or sign up for a free trial license).
- An existing API Testing Project. For details on how to create one, see API Testing Quickstart.
- A Postman Collection (v2.0 or higher).
note
Looking to import from a spec file? See Building a Test from a Spec File.
Importing Postman Collections
- Log in to Sauce Labs, then click API Testing.
- Click to open one of your Projects.
- Click the HTTP Client tab.
- Click the Import OpenAPI/HAR/Postman button, then select and upload your Postman Collection file from your local machine.
tip
If you don't have a file available, try out the sample below.
Click here to open sample Postman Collection file
{
"info": {
"_postman_id": "901ae894-37d4-45c1-b1bc-bd6b31762bfe",
"name": "demoapif",
"description": "Call to the APIF demo API All Products Get.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "product",
"item": [
{
"name": "List All Products",
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"key": "key",
"value": "ABC123",
"type": "text"
}
],
"url": {
"raw": "http://demoapi.apifortress.com/api/retail/product",
"protocol": "http",
"host": [
"demoapi",
"apifortress",
"com"
],
"path": [
"api",
"retail",
"product"
]
}
},
"response": []
}
],
"description": "Folder for product"
}
]
}
- Click the folder your Snapshots tree where you'd like to save your file.
- Click Save.
- The routes from your collection will now show in the list of saved requests.
Importing Postman Environments
- Log in to Sauce Labs, then click API Testing.
- Click to open one of your Projects.
- Click the Vault tab.
- Click Variables.
- Click Import.
- Select and upload your
.postman_environment.json
file.
Your environmental variables will now be available in the Variables section of your Project.
Importing Postman Variables
- Log in to Sauce Labs, then click API Testing.
- Click the Company Vault tab.
- Click the Variables radio button.
- Click Import.
- Select and upload your
.postman_environment.json
file.
Your environmental variables will now available across all your Projects.
Importing a HAR File from an RDC Job
RDC Only
You can import a HAR (HTTP Archive) file into API Testing to automatically generate a functional test. Network Traffic Capture must be enabled to use this feature. See Network Traffic Capture for more information.
To import a HAR file:
In Sauce Labs, click API Testing.
On the Projects page, under the project you want to import the file to, click HTTP Client.
On the HTTP Client page, click Import OpenAPI/Postman, and then click Import Har from RDC Job.
In the Import Snapshots from RDC Jobs window, click a test in the list and then click Import. You can filter this list by job owner or job type.
In the Snapshots panel, navigate to a folder and then click Save.
When the import is complete, in the Snapshots panel, open the folder you imported the files to.
In the folder, click on snapshot to view its details in the response panel.
To create a test based on the imported file, click Generate Test. For more information about creating a test, see Create a Test.