Postman API Collection

  1. Get the Postman collection from a Unit21 Team member or from here
  2. In Postman, select "Import" to import the collection with the collection JSON file. The collection file is in v2.1 format.
1546
  1. Some collection variables need to be configured before the collection is ready for use. Click on options for the imported collection "Unit21 API (Public)" and select "Edit".
1546
  1. Populate the collection variables orgName with your organization name configured (passed to you by a Unit21 team member) and u21-key with the API key that you generated from the Unit21 dashboard.
1546

Here is a sample environment file for sandbox1:

{
	"id": "0279a54d-a6ed-4f43-a5ae-1b1713134757",
	"name": "Unit21-sandbox1",
	"values": [
		{
			"key": "protocol",
			"value": "https",
			"enabled": true
		},
		{
			"key": "host",
			"value": "sandbox1-api.unit21.com",
			"enabled": true
		},
		{
			"key": "randId",
			"value": "38f8e0Rwdf63nld71112345132UeUKFWE123",
			"enabled": true
		},
		{
			"key": "u21-key",
			"value": "54895349_this_is_a_fake_key_4533",
			"enabled": true
		}
	],
	"_postman_variable_scope": "environment",
	"_postman_exported_at": "2021-08-05T16:39:57.216Z",
	"_postman_exported_using": "Postman/7.36.5"
}

The collection is now ready for use.

Notes:

  • Change the randId collection variable to a new value to run a new test that avoids ID collisions. For more convenience, you could create a collection-level script that automatically sets randId to be a random string upon running the first request in the collection e.g.
if (pm.info.requestName == 'create userA') {
    var uuid = require('uuid')
    randId = uuid();
    pm.collectionVariables.set('randId', randId);
}
  • If you encounter 423 LOCKED responses from the API on update or get API requests, it means that the requested object is still being processed. Retrying the request after a delay will result in a successful request.
  • The (OPTIONAL) Sleep 5 S requests are included in the collection between sequences of create, update, and get requests to avoid 424 LOCKED responses when running the collection requests in quick succession i.e. using Postman Collection Runner