Bird
Raised Fist0
Postmantesting~15 mins

Workspace organization in Postman - Build an Automation Script

Choose your learning style10 modes available
Create and organize collections in Postman workspace
Preconditions (2)
Step 1: Open Postman and navigate to the workspace dashboard
Step 2: Create a new workspace named 'API Testing Workspace'
Step 3: Within the workspace, create a new collection named 'User API Tests'
Step 4: Add a GET request to 'https://jsonplaceholder.typicode.com/users' in the collection
Step 5: Save the request with the name 'Get Users'
Step 6: Create another collection named 'Post API Tests'
Step 7: Add a POST request to 'https://jsonplaceholder.typicode.com/posts' with a JSON body in the collection
Step 8: Save the request with the name 'Create Post'
Step 9: Verify that both collections appear under the 'API Testing Workspace'
Step 10: Switch between collections and verify requests are organized correctly
✅ Expected Result: The workspace 'API Testing Workspace' contains two collections named 'User API Tests' and 'Post API Tests'. Each collection contains the correct saved requests. The workspace and collections are organized and accessible.
Automation Requirements - Postman Collection Runner with Newman
Assertions Needed:
Verify workspace creation success
Verify collections exist in the workspace
Verify requests are saved with correct names and URLs
Verify response status code 200 for GET request
Verify response status code 201 for POST request
Best Practices:
Use environment variables for URLs
Use descriptive names for collections and requests
Use Newman CLI for running collections
Use JSON schema validation for response body
Organize tests logically in collections
Automated Solution
Postman
import newman from 'newman';

// Define environment variables
const environment = {
  "id": "env1",
  "name": "Local Environment",
  "values": [
    { "key": "baseUrl", "value": "https://jsonplaceholder.typicode.com", "enabled": true }
  ]
};

// Define the Postman collection JSON
const collection = {
  "info": {
    "name": "API Testing Workspace",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "User API Tests",
      "item": [
        {
          "name": "Get Users",
          "request": {
            "method": "GET",
            "url": "{{baseUrl}}/users"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('Status code is 200', function () {",
                  "    pm.response.to.have.status(200);",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Post API Tests",
      "item": [
        {
          "name": "Create Post",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\"title\": \"foo\", \"body\": \"bar\", \"userId\": 1}"
            },
            "url": "{{baseUrl}}/posts"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('Status code is 201', function () {",
                  "    pm.response.to.have.status(201);",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    }
  ]
};

// Run the collection using Newman
newman.run({
  collection: collection,
  environment: environment,
  reporters: 'cli'
}, function (err, summary) {
  if (err) { throw err; }
  console.log('Collection run complete!');
  // Check if all tests passed
  const failures = summary.run.failures.length;
  if (failures === 0) {
    console.log('All tests passed successfully.');
  } else {
    console.log(`${failures} test(s) failed.`);
  }
});

This script uses Newman, the command-line runner for Postman collections.

We define an environment with a base URL to keep URLs flexible.

The collection JSON defines two collections inside one workspace: 'User API Tests' and 'Post API Tests'. Each has one request with tests checking the HTTP status codes.

Newman runs the collection and outputs results in the console.

This approach follows best practices: environment variables, descriptive names, and test assertions for response codes.

Common Mistakes - 4 Pitfalls
Hardcoding URLs directly in requests without environment variables
Not adding assertions to verify response status codes
Mixing multiple unrelated tests in one collection without organization
Running Newman without specifying environment or collection properly
Bonus Challenge

Now add data-driven testing with 3 different POST request bodies for 'Create Post'

Show Hint

Practice

(1/5)
1. What is the main purpose of a Workspace in Postman?
easy
A. To write code for APIs
B. To organize API tests and related files in one place
C. To deploy APIs to servers
D. To monitor server performance

Solution

  1. Step 1: Understand Workspace Function

    A Workspace in Postman is designed to keep API tests and files organized together.
  2. Step 2: Eliminate Other Options

    Writing code, deploying APIs, and monitoring servers are not the main functions of a Workspace.
  3. Final Answer:

    To organize API tests and related files in one place -> Option B
  4. Quick Check:

    Workspace = Organize tests [OK]
Hint: Workspaces group tests and files for easy access [OK]
Common Mistakes:
  • Confusing Workspace with API deployment
  • Thinking Workspace is for coding APIs
  • Assuming Workspace monitors servers
2. Which of the following is the correct way to create a new Workspace in Postman?
easy
A. Go to Settings and click 'Add Workspace'
B. Right-click on a request and choose 'Create Workspace'
C. Drag and drop a collection into the sidebar
D. Click on 'New' button and select 'Workspace'

Solution

  1. Step 1: Identify Workspace Creation Method

    In Postman, you create a Workspace by clicking the 'New' button and selecting 'Workspace'.
  2. Step 2: Verify Other Options

    Right-clicking requests, using Settings, or drag-and-drop do not create Workspaces.
  3. Final Answer:

    Click on 'New' button and select 'Workspace' -> Option D
  4. Quick Check:

    Create Workspace = New button [OK]
Hint: Use 'New' button to start creating a Workspace [OK]
Common Mistakes:
  • Trying to create Workspace from request right-click
  • Looking in Settings for Workspace creation
  • Dragging collections to create Workspace
3. Consider you have two Workspaces named 'Team API' and 'Personal API'. You switch from 'Personal API' to 'Team API'. What happens to your collections and environments?
medium
A. You see only collections and environments saved in 'Team API' Workspace
B. All collections and environments from both Workspaces are merged and shown
C. Collections and environments from 'Personal API' remain visible
D. Postman deletes collections from 'Personal API'

Solution

  1. Step 1: Understand Workspace Isolation

    Each Workspace in Postman shows only its own collections and environments.
  2. Step 2: Analyze Switching Effect

    Switching to 'Team API' hides 'Personal API' collections; no merging or deletion occurs.
  3. Final Answer:

    You see only collections and environments saved in 'Team API' Workspace -> Option A
  4. Quick Check:

    Workspace switch = show own data only [OK]
Hint: Switching Workspace shows only its own collections [OK]
Common Mistakes:
  • Thinking collections merge across Workspaces
  • Assuming collections stay visible after switch
  • Believing Postman deletes collections on switch
4. You created a Workspace but your team members cannot see it. What is the most likely reason?
medium
A. The Workspace is private and not shared with the team
B. The Workspace name is too long
C. You did not add any collections yet
D. Postman does not support team Workspaces

Solution

  1. Step 1: Check Workspace Sharing Settings

    By default, Workspaces can be private; team members cannot see private Workspaces unless shared.
  2. Step 2: Evaluate Other Options

    Workspace name length, empty collections, or Postman features do not block visibility.
  3. Final Answer:

    The Workspace is private and not shared with the team -> Option A
  4. Quick Check:

    Private Workspace = team can't see [OK]
Hint: Share Workspace to let team members access it [OK]
Common Mistakes:
  • Assuming name length affects visibility
  • Thinking empty collections hide Workspace
  • Believing Postman lacks team Workspace support
5. You want to organize your API tests so that your team can collaborate easily and find tests quickly. Which combination of Workspace practices is best?
hard
A. Keep all tests in one Workspace without sharing to avoid confusion
B. Create many private Workspaces with vague names to separate tests
C. Use clear Workspace names, share Workspace with team, and group related collections inside
D. Use Workspace only for personal tests and share collections separately

Solution

  1. Step 1: Identify Best Practices for Team Collaboration

    Clear names, sharing Workspaces, and grouping related collections help teamwork and easy finding.
  2. Step 2: Reject Poor Practices

    Private vague Workspaces, no sharing, or separating collections outside Workspace reduce collaboration and clarity.
  3. Final Answer:

    Use clear Workspace names, share Workspace with team, and group related collections inside -> Option C
  4. Quick Check:

    Clear names + share + group = best practice [OK]
Hint: Clear names and sharing improve teamwork [OK]
Common Mistakes:
  • Making Workspaces private only
  • Using unclear Workspace names
  • Avoiding sharing to prevent confusion
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard