Postman

Postman

Top Interview Questions

About Postman

 

Postman: An Overview

Postman is a powerful and widely used tool for API development, testing, and management. Originally created as a Chrome extension in 2012, Postman has evolved into a full-fledged desktop and web application, supporting Windows, Mac, and Linux platforms. It provides developers and testers with a user-friendly interface to interact with APIs without writing complex code, thereby simplifying the entire API lifecycle. Postman enables the sending of HTTP requests, receiving responses, debugging, testing, and automating APIs effectively.

APIs (Application Programming Interfaces) are the backbone of modern web and mobile applications. They allow different software systems to communicate, share data, and perform operations. Testing APIs is critical to ensure functionality, security, and performance. Postman bridges the gap between backend developers, frontend developers, QA testers, and business analysts by providing an intuitive platform to work with APIs efficiently.


Key Features of Postman

Postman is rich in features, making it more than just an API testing tool. Some of the notable features include:

  1. Request Building:
    Postman allows users to create and send HTTP requests using various methods like GET, POST, PUT, DELETE, PATCH, and OPTIONS. It supports URL parameters, headers, authentication, and body payloads in different formats such as JSON, XML, or form-data.

  2. Environment Management:
    Postman lets users define environments to store variables like API keys, tokens, URLs, or other dynamic data. This helps in switching between development, testing, staging, and production environments effortlessly.

  3. Collections:
    Collections are a group of saved requests organized logically for a project. Collections can be shared among team members, enabling collaboration and standardization in testing.

  4. Automated Testing with Scripts:
    Postman supports pre-request scripts and test scripts written in JavaScript. Users can perform validations, assertions, or data transformations automatically before sending a request or after receiving a response.

  5. Mock Servers:
    Postman provides the ability to create mock servers, which simulate API responses even before the actual backend is ready. This is particularly useful for frontend developers to start working without waiting for backend completion.

  6. API Documentation:
    Postman can automatically generate API documentation based on the requests and collections. This documentation can be published and shared, helping developers and testers understand API functionality without needing separate documents.

  7. Monitoring:
    Postman monitors allow scheduled execution of API requests to check their performance and uptime. This ensures that APIs are functioning as expected over time and can alert teams if there are issues.

  8. Collaboration Tools:
    Postman supports teamwork through workspaces, version control, and collaboration features. Teams can work on the same collections, track changes, and maintain a single source of truth.

  9. Integration with CI/CD:
    Postman can be integrated into Continuous Integration/Continuous Deployment (CI/CD) pipelines using tools like Jenkins, GitHub Actions, GitLab CI, or Azure DevOps. This allows automated testing of APIs during the deployment process.


Benefits of Using Postman

Postman provides several advantages, making it an essential tool in the software development lifecycle:

  1. User-Friendly Interface:
    With an intuitive GUI, Postman makes API interaction easy, even for beginners who are not very familiar with HTTP requests and backend systems.

  2. Time-Saving:
    By eliminating the need to write code for basic API testing and automating repetitive tasks with collections and scripts, Postman drastically reduces development and testing time.

  3. Supports Multiple API Types:
    Postman can work with REST, SOAP, GraphQL, and WebSocket APIs, making it versatile for different projects.

  4. Enhanced Collaboration:
    Team features allow multiple users to work together on API development and testing, enhancing communication and reducing errors.

  5. Error Detection and Debugging:
    Postman provides detailed information about responses, status codes, headers, and body content, helping developers quickly identify and fix issues.

  6. Security Testing:
    Postman supports various authentication methods like Basic Auth, OAuth 2.0, JWT, API keys, and custom headers, helping testers validate secure access to APIs.

  7. Scalability:
    Postman is suitable for individual developers working on small projects as well as large enterprises managing hundreds of APIs.


Uses of Postman

Postman serves multiple purposes across different roles:

  1. For Developers:
    Developers use Postman to test APIs during development, debug issues, validate endpoints, and simulate requests and responses.

  2. For QA Testers:
    Testers use Postman to automate functional testing, perform regression testing, and ensure that APIs meet expected behavior and performance standards.

  3. For Business Analysts:
    Analysts can explore APIs using Postman to understand data flow and endpoints without diving into backend code, helping in requirement analysis and project planning.

  4. For DevOps Teams:
    Postman’s integration with CI/CD pipelines allows DevOps teams to perform automated API tests during builds and deployments, ensuring high-quality releases.

  5. For Learning and Training:
    Postman provides a great platform for learning API concepts and experimenting with requests, making it popular in educational settings and training programs.


Postman in Modern Development Workflows

Postman has become an indispensable part of modern software development. With the rise of microservices architecture, cloud-based APIs, and mobile-first applications, the need for efficient API testing and management has increased. Postman fits perfectly into agile development methodologies by enabling continuous testing, rapid prototyping, and seamless collaboration.

For instance, during an agile sprint, a backend developer can create new API endpoints and immediately test them using Postman. Meanwhile, frontend developers can use mock servers to simulate responses and continue their development without waiting for backend readiness. QA testers can write automated scripts in Postman to validate these APIs across multiple environments. The team can then share collections and environments within Postman workspaces, ensuring everyone stays on the same page.


Postman vs Other API Testing Tools

While there are other tools available for API testing, such as SoapUI, Swagger, Insomnia, and JMeter, Postman stands out due to its ease of use, rich feature set, and active community. SoapUI is more focused on SOAP APIs and enterprise-level testing, while Postman is versatile for both REST and SOAP. Swagger is primarily used for API documentation and design, whereas Postman combines testing, automation, and documentation in one platform. Insomnia is lightweight and visually appealing but lacks some advanced collaboration and monitoring features that Postman offers. JMeter is excellent for load testing, but Postman provides a more accessible interface for functional testing and automation.


Learning Postman for Freshers

For freshers entering IT or software testing, learning Postman is highly recommended. Knowledge of Postman not only helps in testing APIs but also demonstrates familiarity with modern development tools and workflows, making candidates more attractive to potential employers. Understanding Postman’s features like collections, environments, scripting, and monitors provides a solid foundation for working on backend testing, DevOps practices, and API-driven projects.

Freshers can start by learning the basics:

  1. Understanding HTTP methods and status codes.

  2. Creating requests and analyzing responses.

  3. Using environments and variables for dynamic testing.

  4. Writing simple test scripts for response validation.

  5. Creating and sharing collections for collaborative work.

As they progress, they can explore advanced features like mock servers, monitors, and CI/CD integration, which are valuable skills in real-world projects.

Fresher Interview Questions

 

1. What is Postman?

Answer:
Postman is a popular API (Application Programming Interface) testing tool that allows developers to design, test, and document APIs. It provides a user-friendly interface to send HTTP requests (GET, POST, PUT, DELETE, etc.) and view responses. It is widely used for manual API testing, automation, and collaboration among teams.

Key Points:

  • Supports REST, SOAP, and GraphQL APIs.

  • Allows environment management and scripting.

  • Provides automated testing through Postman Collections.


2. What are the key features of Postman?

Answer:

  1. User-friendly interface – easy to create and send requests.

  2. Supports all HTTP methods – GET, POST, PUT, DELETE, PATCH, OPTIONS, etc.

  3. Environment and variable support – for storing dynamic values.

  4. Collections – group requests for testing workflows.

  5. Automated Testing – using scripts written in JavaScript.

  6. Mock Servers – simulate API responses.

  7. Monitoring – check APIs performance over time.

  8. Collaboration – share collections and documentation with teams.


3. What is the difference between GET and POST request in Postman?

Answer:

Method Description Usage
GET Requests data from a server Fetch user data, read info
POST Sends data to the server to create/update Add new user, create record

Example in Postman:

  • GET: https://api.example.com/users/1 – retrieves user details.

  • POST: https://api.example.com/users – sends JSON data to create a new user.


4. What is a Postman Collection?

Answer:
A Collection is a group of saved API requests in Postman. It helps organize requests by project or functionality. Collections can also include tests, pre-request scripts, and variables.

Use Case:

  • Automating API testing.

  • Sharing APIs with team members.

  • Running requests sequentially using Collection Runner.


5. What is a Postman Environment?

Answer:
An Environment in Postman is a set of key-value pairs that can be used to store variables such as API URLs, authentication tokens, or user IDs. It allows you to switch between different setups (like dev, staging, production) without changing the request manually.

Example:

  • Environment variable: {{baseUrl}} = https://api.example.com

  • Request URL: {{baseUrl}}/users

Switching environments changes the base URL automatically.


6. What are Pre-request and Test scripts in Postman?

Answer:

  • Pre-request Script: Code (JavaScript) executed before the request is sent. Used for generating tokens, timestamps, or modifying request headers dynamically.

    Example: Generate a timestamp:

    pm.environment.set("timestamp", new Date().toISOString());
    
  • Test Script: Code executed after the request is completed. Used for validating responses, status codes, or extracting data.

    Example: Check status code is 200:

    pm.test("Status code is 200", function () {
        pm.response.to.have.status(200);
    });
    

7. What are variables in Postman and types of variables?

Answer:
Variables store dynamic values and can be used across requests. Types of variables:

  1. Global Variables: Available in all collections and environments.

  2. Environment Variables: Specific to an environment (dev, staging, prod).

  3. Collection Variables: Available within a specific collection.

  4. Local Variables: Available only in the current request.

  5. Data Variables: Used in data-driven tests (from CSV/JSON files).

Example:
{{userId}} – dynamically replaced during request execution.


8. How can you automate tests in Postman?

Answer:
Automation is done using Collections and Collection Runner:

  1. Save all requests in a collection.

  2. Write test scripts to validate responses.

  3. Use Collection Runner to run multiple requests in sequence.

  4. Optionally, use data files (CSV/JSON) for data-driven tests.

  5. Use Postman Monitors to schedule automated runs.

Example Test Script:

pm.test("Response time is less than 200ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(200);
});

9. What is a Mock Server in Postman?

Answer:
A Mock Server simulates an API response without the real backend. Useful for front-end developers to continue work when the backend is not ready.

Steps to create:

  1. Save request and response in a collection.

  2. Click “Mock Server” in Postman.

  3. Use the mock URL in your application to test API calls.


10. What are the advantages of using Postman?

Answer:

  1. Easy to use for both beginners and experienced developers.

  2. Supports automated testing and monitoring.

  3. Centralized API documentation.

  4. Collaboration via Workspaces and shared collections.

  5. Reduces dependency on the backend with mock servers.

  6. Integrates with CI/CD tools for DevOps.


11. Difference between PUT and PATCH request

Method Description Use Case
PUT Updates the entire resource Update user info completely
PATCH Updates specific fields of a resource Update user email only

12. How to pass authorization in Postman?

Answer:
Postman supports multiple authorization types:

  1. No Auth

  2. API Key – pass key in headers or query parameters.

  3. Bearer Token – usually JWT.

  4. Basic Auth – username and password.

  5. OAuth 1.0/2.0 – for secured APIs.

Example (Bearer Token):

  • Go to Authorization → Bearer Token → Enter token value → Send request.


13. What is the difference between Postman and Swagger?

Feature Postman Swagger
Purpose API testing, automation, collaboration API documentation and design
UI Rich interactive interface Documentation-focused
Testing Supports automated tests Limited testing
Collaboration Yes, team workspaces Mostly documentation

14. What is Collection Runner and how to use it?

Answer:
Collection Runner allows you to run multiple requests from a collection in a sequence automatically.

Steps:

  1. Open Postman → Collections → Select collection → Click “Run”.

  2. Choose environment and iteration count.

  3. Optionally, upload a data file (CSV/JSON) for data-driven testing.

  4. Click Run and view results.


15. How to handle dynamic data in Postman?

Answer:
Dynamic data can be handled using:

  1. Variables – environment, global, collection, or local.

  2. Pre-request scripts – generate timestamps, tokens, random values.

  3. Data files – use CSV or JSON to feed multiple sets of input values.

Example: Random email:

pm.environment.set("randomEmail", `user${Math.floor(Math.random()*1000)}@example.com`);

16. How to test response in Postman?

Answer:

  1. Status code: pm.response.to.have.status(200);

  2. Response time: pm.expect(pm.response.responseTime).to.be.below(500);

  3. Response body: pm.expect(pm.response.text()).to.include("success");

  4. JSON value:

let jsonData = pm.response.json();
pm.expect(jsonData.name).to.eql("John");

17. Can Postman be integrated with Jenkins or CI/CD tools?

Answer:
Yes. Postman collections can be exported and run using Newman CLI (command-line tool). Newman can be integrated with CI/CD pipelines like Jenkins, GitHub Actions, or GitLab CI to automate API testing.

Command example:

newman run collection.json -e environment.json

18. What are some best practices in Postman?

Answer:

  1. Organize requests using collections and folders.

  2. Use environment variables for dynamic values.

  3. Write reusable scripts for tests and pre-request tasks.

  4. Use descriptive names for requests and variables.

  5. Regularly update and maintain collections.

  6. Share collections for collaboration.

  7. Use mock servers for frontend-backend independence.


19. What is Newman in Postman?

Answer:
Newman is a command-line tool used to run Postman collections outside the Postman GUI. It allows integration with CI/CD pipelines (like Jenkins, GitHub Actions) for automated API testing.

Usage Example:

newman run collection.json -e environment.json
  • collection.json → exported Postman collection

  • environment.json → exported environment file

Advantages:

  • Automates testing in CI/CD pipelines.

  • Supports reporting in HTML, JSON, or CLI.

  • Enables scheduled API testing using scripts.


20. What is the difference between Postman Sandbox and Pre-request Script?

Feature Postman Sandbox Pre-request Script
Definition JavaScript execution environment in Postman Script executed before sending a request
Use Used for all scripts (tests, pre-request) Generate tokens, timestamps, or manipulate variables before request
Scope All scripts Only for a particular request or collection

Example (Sandbox):

pm.environment.set("currentDate", new Date().toISOString());

21. What is a Postman Monitor?

Answer:
Postman Monitors automatically run collections at scheduled intervals. It helps in checking API performance, uptime, and response validity.

Steps to create:

  1. Go to your collection → Click “Monitor” → Create a monitor.

  2. Set schedule (daily, hourly, etc.).

  3. Select environment, and receive notifications for failures.

Use Case:

  • Monitor a payment API to ensure it is returning valid responses.

  • Detect API downtime automatically.


22. Explain how to handle authorization tokens dynamically in Postman.

Answer:
Tokens can be dynamically handled using pre-request scripts and environment variables.

Example:

pm.sendRequest({
    url: 'https://api.example.com/get-token',
    method: 'POST',
    header: { 'Content-Type': 'application/json' },
    body: {
        mode: 'raw',
        raw: JSON.stringify({ username: 'user', password: 'pass' })
    }
}, function (err, res) {
    pm.environment.set('authToken', res.json().token);
});

Then, in the Authorization header of your main request:

Bearer {{authToken}}

23. How do you validate JSON response in Postman?

Answer:
You can parse the response JSON and validate values using pm.response.json().

Example:

let jsonData = pm.response.json();
pm.test("Check user name", function () {
    pm.expect(jsonData.name).to.eql("John");
});
pm.test("Check status is active", function () {
    pm.expect(jsonData.status).to.eql("active");
});

24. What are Postman Workspaces?

Answer:
Workspaces allow collaboration and separation of projects in Postman.

Types of Workspaces:

  1. Personal Workspace – Private workspace for individual use.

  2. Team Workspace – Shared workspace for collaboration with team members.

Use Case:

  • Developers can work on APIs individually in personal workspace.

  • QA team can share collections and environments in a team workspace.


25. What are the types of tests you can perform in Postman?

Answer:

  1. Status code checkpm.response.to.have.status(200);

  2. Response time checkpm.expect(pm.response.responseTime).to.be.below(500);

  3. Response body contentpm.expect(pm.response.text()).to.include("success");

  4. JSON schema validation – ensures response structure is correct.

  5. Header validation – verify content-type or other headers.

  6. Chaining requests – passing data from one request to another.


26. How to perform data-driven testing in Postman?

Answer:
Data-driven testing allows running the same request with multiple data sets using CSV or JSON files.

Steps:

  1. Prepare CSV or JSON with test data:

username,password
user1,pass1
user2,pass2
  1. Open Collection Runner → Select data file → Run collection.

  2. Postman iterates through each row and executes requests.


27. What is JSON Schema Validation in Postman?

Answer:
JSON Schema Validation ensures the API response structure matches expected design.

Example:

const schema = {
  type: "object",
  properties: {
    id: { type: "number" },
    name: { type: "string" },
    email: { type: "string" }
  },
  required: ["id", "name", "email"]
};
pm.test('Schema is valid', function() {
    pm.response.to.have.jsonSchema(schema);
});

28. How can you chain requests in Postman?

Answer:
You can pass data between requests using environment variables or global variables.

Example:

  1. First request: Get user ID → save in environment variable.

let jsonData = pm.response.json();
pm.environment.set("userId", jsonData.id);
  1. Second request: Use {{userId}} in URL or body.


29. How to debug a failing test in Postman?

Answer:

  1. Check the console (View → Show Postman Console).

  2. Log response or variables using:

console.log(pm.response.text());
console.log(pm.environment.get("userId"));
  1. Validate test scripts carefully for syntax errors.

  2. Verify request URL, headers, and body are correct.


30. Difference between Postman and SoapUI

Feature Postman SoapUI
Best For REST APIs, manual testing, automation SOAP APIs, enterprise-level testing
Interface User-friendly, GUI More technical, GUI-based
Scripting JavaScript (Pre-request & Tests) Groovy scripting
Mocking Supported Supported
Team Collaboration Easy Limited (Pro version needed)

31. What is the difference between Collection Variables and Environment Variables?

Feature Collection Variables Environment Variables
Scope Only available within the collection Available in the selected environment
Use Case Specific to collection workflow Can be reused across multiple collections
Example {{apiKey}} for one collection {{baseUrl}} for dev/staging/prod

32. What are common challenges when using Postman?

Answer:

  1. Handling dynamic data across multiple requests.

  2. Keeping environment variables updated for multiple stages.

  3. Managing large collections efficiently.

  4. Debugging complex test scripts.

  5. Ensuring team collaboration without version conflicts.


33. What is the difference between Status Code 200 and 201?

Status Code Meaning
200 OK Request successful, data returned
201 Created Resource successfully created on the server

34. What are some best practices for Postman scripting?

Answer:

  1. Use environment variables instead of hard-coded values.

  2. Write reusable functions in scripts.

  3. Keep test scripts simple and modular.

  4. Use JSON schema for response validation.

  5. Document scripts and collections clearly.


35. What is the difference between REST and SOAP APIs?

Answer:

Feature REST SOAP
Protocol HTTP XML-based protocol
Data format JSON, XML, Text XML
Performance Lightweight, faster Heavy, slower
Flexibility High, can use multiple data formats Strict, standards-based
Caching Supported Not supported
Security OAuth, JWT WS-Security

Use Case in Postman:

  • REST APIs are easier to test and automate in Postman.

  • SOAP requests require XML body and SoapAction headers.


36. How to test SOAP API in Postman?

Answer:

  1. Set method to POST.

  2. Add the SOAP endpoint URL.

  3. Set Content-Type header to text/xml.

  4. Add SOAP XML body in the request.

  5. Send request and validate response using test scripts.

Example Test Script:

pm.test("Check SOAP response contains success", function() {
    pm.response.to.have.body("Success");
});

37. Explain environment and global variables difference with examples.

Answer:

Feature Environment Variable Global Variable
Scope Limited to selected environment Available in all environments
Example {{baseUrl}} for dev/staging/prod {{authToken}} shared across collections
Use Case Switching environments easily Reusing common values like tokens or IDs

Example:

  • Environment: {{baseUrl}} = https://dev.api.com

  • Global: {{authToken}} = abc123xyz


38. How to validate a specific header in response?

Answer:
Use Postman test scripts to check headers.

Example:

pm.test("Content-Type is JSON", function () {
    pm.response.to.have.header("Content-Type", "application/json; charset=utf-8");
});

39. How do you handle dynamic endpoints in Postman?

Answer:
Use path variables or environment variables.

Example:
Endpoint: https://api.example.com/users/:userId

  • Path variable: userId = 123

  • Or use environment variable: https://api.example.com/users/{{userId}}


40. What is the difference between raw, form-data, x-www-form-urlencoded in Postman?

Type Description Use Case
Raw Send data in JSON, text, or XML format Sending JSON payload in POST/PUT
form-data Send key-value pairs for multipart data File upload or form submission
x-www-form-urlencoded Key-value pairs URL-encoded Standard web forms

41. How do you perform OAuth 2.0 authentication in Postman?

Answer:

  1. Go to Authorization tab → Select OAuth 2.0.

  2. Click Get New Access Token.

  3. Enter Client ID, Client Secret, Auth URL, Token URL.

  4. Click Request Token → Use token in request header automatically.


42. How to handle cookies in Postman?

Answer:

  • Postman automatically stores cookies for responses.

  • View cookies → Click “Cookies” button.

  • You can add, delete, or modify cookies for a request.

Example Test Script:

pm.test("Check session cookie exists", function() {
    let cookies = pm.cookies.get("session_id");
    pm.expect(cookies).to.not.be.undefined;
});

43. How do you test asynchronous APIs in Postman?

Answer:

  • Asynchronous APIs return responses after some delay.

  • You can test using setTimeout in pre-request or check status code in repeated requests.

  • Optionally, use Postman monitors to retry until expected response arrives.


44. How do you debug failing requests?

Answer:

  1. Open Postman Console (View → Show Postman Console).

  2. Log variables and response:

console.log(pm.response.text());
console.log(pm.environment.get("userId"));
  1. Check request URL, headers, and body.

  2. Validate authentication and environment settings.


45. How to handle rate-limiting APIs in Postman?

Answer:

  • Many APIs limit requests per minute/hour.

  • Use setTimeout in pre-request scripts for delay.

  • Use Collection Runner with delay option:

    • Specify delay between requests in milliseconds.

  • Check response headers like X-RateLimit-Remaining to avoid hitting limits.


46. How to chain multiple requests in Collection Runner?

Answer:

  1. Save requests in a collection.

  2. Set environment variables in first request:

let jsonData = pm.response.json();
pm.environment.set("userId", jsonData.id);
  1. Use {{userId}} in the next request URL or body.

  2. Collection Runner executes requests in sequence with dynamic data.


47. How do you handle file uploads in Postman?

Answer:

  • Use form-data in body.

  • Key: parameter name, Type: File, Value: select file.

Example:

  • Key: profile_pic → Choose file

  • POST request → Upload image or CSV file to API.


48. How to run Postman collection in Jenkins using Newman?

Answer:

  1. Install Newman on Jenkins server:

npm install -g newman
  1. Export Postman collection and environment JSON.

  2. Create a Jenkins pipeline or freestyle job:

newman run collection.json -e environment.json -r cli,html
  1. Schedule the job or trigger via webhook.

  2. View test reports (CLI or HTML).


49. How to mock API responses in Postman?

Answer:

  • Create a mock server from a collection.

  • Postman generates a URL for the mock server.

  • Frontend can use mock URL before backend is ready.

  • Responses can be static or dynamic using scripts.


50. How to use Postman for performance testing?

Answer:

  • Postman is not a full-fledged performance tool like JMeter, but can simulate some load:

  1. Use Collection Runner with iterations.

  2. Add delay between requests.

  3. Measure response time using pm.response.responseTime.

  4. Use Newman CLI to run multiple iterations.

Example:

pm.test("Response time is less than 200ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(200);
});

51. What is the difference between Postman Free and Postman Pro/Enterprise?

Feature Free Pro/Enterprise
Team Collaboration Limited Full access to shared workspaces
Monitors Limited Unlimited monitoring
API Documentation Basic Customizable with publishing options
Version Control No Full version control and rollback
Mock Servers Limited Unlimited

52. How to validate JSON array response in Postman?

Example:

let jsonData = pm.response.json();
pm.test("Check number of users", function () {
    pm.expect(jsonData.length).to.be.above(0);
});
pm.test("Check first user name", function () {
    pm.expect(jsonData[0].name).to.eql("John");
});

53. How to test negative scenarios in Postman?

Answer:

  • Send invalid data or missing fields.

  • Validate error response code and message:

pm.test("Should return 400 Bad Request", function () {
    pm.response.to.have.status(400);
});
pm.test("Check error message", function () {
    pm.expect(pm.response.text()).to.include("Invalid email");
});

54. How to use Postman for GraphQL APIs?

Answer:

  1. Select POST method.

  2. Enter GraphQL endpoint.

  3. Set body type to GraphQL.

  4. Enter query or mutation.

  5. Send request → Validate response.

Example Query:

{
  user(id: "1") {
    name
    email
  }
}

55. How do you handle dynamic headers or authorization?

Answer:

  • Use environment variables and pre-request scripts.
    Example:

pm.environment.set("authHeader", "Bearer " + pm.environment.get("authToken"));
  • Use {{authHeader}} in headers for dynamic authorization.

Experienced Interview Questions

 

1. What are the key differences between using Postman as a beginner and for advanced automation?

Answer:

  • Beginner level: Manual API testing, sending GET/POST requests, using simple variables, saving collections.

  • Advanced level:

    • Writing complex pre-request and test scripts using JavaScript.

    • Chaining multiple requests using environment and collection variables.

    • Using Newman for CI/CD integration and automated regression testing.

    • Creating data-driven tests using CSV/JSON.

    • Performance checks and monitoring APIs with Postman Monitors.


2. Explain the concept of Collection Runner with data files. How is it used in automation?

Answer:

  • Collection Runner allows you to execute multiple requests in sequence.

  • Data files (CSV/JSON) allow running the same collection with multiple test data sets (data-driven testing).

  • Use Case:

    • Testing user login with multiple username/password combinations.

    • Validating CRUD operations for multiple records.

  • Example:

    1. Prepare CSV:

    username,password
    user1,pass1
    user2,pass2
    
    1. Run collection → select data file → results are generated for each row.


3. How do you integrate Postman tests into a CI/CD pipeline?

Answer:

  1. Export Postman collection and environment JSON files.

  2. Install Newman CLI on Jenkins, GitLab CI, GitHub Actions, or any CI server.

npm install -g newman
newman run collection.json -e environment.json -r cli,html
  1. Add Newman command in pipeline scripts to automate testing.

  2. Generate reports (HTML, JSON) for CI/CD dashboards.

  3. Schedule periodic automated API testing using monitors or cron jobs.


4. Explain chaining requests and dynamic variable usage in Postman.

Answer:

  • Chaining requests: Using data from one request in subsequent requests.

  • Example:

    1. First request: Create a user → store user ID:

    let jsonData = pm.response.json();
    pm.environment.set("userId", jsonData.id);
    
    1. Second request: Use {{userId}} in URL to update user.

  • Dynamic variables: Automatically generate timestamps, random values, or tokens using pre-request scripts:

pm.environment.set("randomEmail", `user${Math.floor(Math.random()*1000)}@mail.com`);

5. How do you handle authentication for multiple environments?

Answer:

  • Use environment variables for base URLs and tokens.

  • Store tokens dynamically in pre-request scripts:

pm.sendRequest({
    url: pm.environment.get("authUrl"),
    method: 'POST',
    header: { 'Content-Type': 'application/json' },
    body: { mode: 'raw', raw: JSON.stringify({ username: 'user', password: 'pass' }) }
}, function(err, res) {
    pm.environment.set("authToken", res.json().token);
});
  • Use {{authToken}} in headers across all environments (dev, staging, prod).


6. Explain how to perform data-driven testing in Postman with Newman.

Answer:

  • Steps:

    1. Create a collection with test requests.

    2. Prepare CSV or JSON with test data.

    3. Run collection in Newman:

    newman run collection.json -e environment.json --iteration-data data.csv -r cli,html
    
  • Use Case: Validate API with multiple test inputs, like user registration with different email IDs.

  • Generates detailed reports showing pass/fail for each data set.


7. How do you validate API response schemas in Postman?

Answer:

  • Use JSON schema validation in test scripts:

const schema = {
    type: "object",
    properties: {
        id: { type: "number" },
        name: { type: "string" },
        email: { type: "string" }
    },
    required: ["id", "name", "email"]
};
pm.test("Schema is valid", function () {
    pm.response.to.have.jsonSchema(schema);
});
  • Ensures API response structure is consistent and correct.

  • Crucial for automated regression testing in CI/CD pipelines.


8. How do you handle asynchronous API testing in Postman?

Answer:

  • Some APIs (webhooks, delayed processing) respond asynchronously.

  • Techniques:

    1. Poll API repeatedly until the expected status is received.

    2. Use setTimeout in pre-request scripts to add delays.

    3. Validate status codes and response content dynamically.

  • Example:

pm.test("Check status is completed", function() {
    let status = pm.response.json().status;
    pm.expect(status).to.eql("completed");
});

9. How do you debug complex test failures in Postman?

Answer:

  • Use Postman Console (View → Show Postman Console).

  • Log request/response data:

console.log(pm.response.text());
console.log(pm.environment.get("userId"));
  • Validate:

    • Request URL, headers, body

    • Environment variables and token values

    • Status codes and response structure

  • Advanced debugging: Use Newman logs with --reporters cli,json to track failures in CI/CD pipelines.


10. How do you use Postman monitors for advanced testing?

Answer:

  • Monitors automatically run collections on a schedule.

  • Use Cases:

    1. Monitor API uptime and response time.

    2. Execute regression tests daily or hourly.

    3. Generate reports and alerts on failures.

Steps:

  1. Select collection → Create monitor → Set schedule → Choose environment.

  2. Receive notifications via email or webhook.


11. How to integrate Postman with Git for version control?

Answer:

  • Export collections and environments → Save in a Git repository.

  • Use Postman API or CLI tools to push updates automatically.

  • Maintain version control for collections and scripts.

  • Enables team collaboration with rollback options.


12. Explain how to test GraphQL APIs in Postman.

Answer:

  1. Set POST method and endpoint URL.

  2. Select GraphQL body type.

  3. Enter query or mutation:

{
  user(id: "1") {
    id
    name
    email
  }
}
  1. Add variables if required.

  2. Send request and validate response using test scripts.


13. How do you handle large API collections efficiently?

Answer:

  • Use folders to group related requests.

  • Use collection variables for shared data within the folder.

  • Maintain modular pre-request and test scripts to reduce redundancy.

  • Use tags and naming conventions to identify requests quickly.


14. How do you handle versioning of APIs in Postman?

Answer:

  • Maintain separate collections for different API versions (v1, v2, v3).

  • Use environment variables to switch between base URLs.

  • Example:

{{baseUrl}}/v1/users
{{baseUrl}}/v2/users
  • Helps regression testing and backward compatibility validation.


15. How to use dynamic headers and tokens in advanced scenarios?

Answer:

  • Use pre-request scripts to dynamically generate tokens or headers.

  • Example: HMAC token generation:

const crypto = require('crypto');
let timestamp = new Date().toISOString();
let secret = pm.environment.get("secretKey");
let token = crypto.createHmac('sha256', secret).update(timestamp).digest('hex');
pm.environment.set("authToken", token);
  • Then use {{authToken}} in request headers.


16. How do you test API rate limits and throttling in Postman?

Answer:

  • Use Collection Runner with iteration delay.

  • Example: Run 100 requests with 500ms delay to check API throttling.

  • Validate response codes for rate-limit errors (e.g., 429 Too Many Requests).

  • Check response headers like X-RateLimit-Remaining or Retry-After.


17. Explain how to perform negative testing with Postman.

Answer:

  • Send invalid or missing data to validate error handling.

  • Example: Missing required field in POST request:

pm.test("Return 400 Bad Request", function () {
    pm.response.to.have.status(400);
});
pm.test("Error message is correct", function () {
    pm.expect(pm.response.text()).to.include("email is required");
});
  • Ensures API handles invalid input gracefully.


18. How to handle SOAP APIs with dynamic XML in Postman?

Answer:

  • Use POST method with XML body.

  • Use variables for dynamic values in XML:

<soapenv:Envelope>
   <soapenv:Body>
      <GetUser>
         <id>{{userId}}</id>
      </GetUser>
   </soapenv:Body>
</soapenv:Envelope>
  • Validate response using xml2Json or XPath in test scripts.


19. How to run Postman tests in headless mode for automation?

Answer:

  • Use Newman CLI to run collections without GUI.

  • Generate reports in JSON, HTML, or JUnit format:

newman run collection.json -e environment.json -r cli,html,junit
  • Integrate into CI/CD for scheduled regression testing.


20. What are Postman Workspaces and how do you use them in a team environment?

Answer:

  • Workspaces allow team members to collaborate on collections, environments, and APIs.

  • Types:

    1. Personal Workspace: Private, for individual testing.

    2. Team Workspace: Shared with multiple users for collaboration.

  • Use Case:

    • Developers create and test APIs.

    • QA validates the same collection.

    • Shared environments ensure consistent testing data.

Advanced Tip: Use role-based access control in enterprise workspaces to manage permissions.


21. Explain how to handle environment and global variables dynamically across multiple collections.

Answer:

  • Environment variables: Specific to a project environment (dev, staging, prod).

  • Global variables: Can be accessed across multiple collections.

  • Dynamic updates:

let jsonData = pm.response.json();
pm.environment.set("userId", jsonData.id);
pm.globals.set("authToken", jsonData.token);
  • Use Case: Run multiple collections that share a token or common URL.


22. How do you perform API regression testing with Postman and Newman?

Answer:

  1. Maintain a master collection for all API endpoints.

  2. Write robust test scripts for status codes, response body, headers, and schema.

  3. Run the collection via Newman:

newman run master_collection.json -e environment.json -r cli,html
  1. Schedule regression tests in CI/CD pipelines using Jenkins, GitLab, or GitHub Actions.

  2. Validate results using HTML/JSON reports.


23. How do you handle response chaining with multiple dependent requests?

Answer:

  • Store values from one request in environment or collection variables.

  • Example scenario: Create a user → Get user ID → Update user → Delete user.

let jsonData = pm.response.json();
pm.environment.set("userId", jsonData.id);
  • Subsequent requests use {{userId}} in URL or body.

  • Advanced Tip: Use pre-request scripts to compute dynamic data before chained requests.


24. How do you validate response headers and cookies in Postman?

Answer:

  • Validate headers:

pm.test("Content-Type is JSON", function() {
    pm.response.to.have.header("Content-Type", "application/json; charset=utf-8");
});
  • Validate cookies:

pm.test("Session cookie exists", function() {
    let cookie = pm.cookies.get("session_id");
    pm.expect(cookie).to.not.be.undefined;
});
  • Useful for authentication, caching, or security testing.


25. How do you perform performance testing using Postman?

Answer:

  • Postman is limited but can simulate basic load tests:

  1. Run collection using Collection Runner with multiple iterations.

  2. Add delay between requests.

  3. Measure response times in scripts:

pm.test("Response time < 500ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(500);
});
  1. Use Newman for running multiple iterations in CI/CD.

  • Advanced Tip: For high-scale performance testing, integrate Postman with JMeter or k6.


26. How do you automate token generation in Postman for multiple requests?

Answer:

  • Use a pre-request script to fetch a token dynamically and store it in environment variables:

pm.sendRequest({
    url: pm.environment.get("authUrl"),
    method: "POST",
    header: { "Content-Type": "application/json" },
    body: { mode: "raw", raw: JSON.stringify({ username: "user", password: "pass" }) }
}, function(err, res) {
    pm.environment.set("authToken", res.json().token);
});
  • Use {{authToken}} in Authorization headers of all requests.


27. How do you handle GraphQL queries with variables and testing in Postman?

Answer:

  • Use POST method → Select GraphQL body type.

  • Add query or mutation and variables:

query getUser($id: ID!) {
  user(id: $id) {
    name
    email
  }
}
  • Variables JSON:

{ "id": "1" }
  • Test responses dynamically:

pm.test("User name is John", function () {
    let jsonData = pm.response.json();
    pm.expect(jsonData.data.user.name).to.eql("John");
});

28. How do you test SOAP APIs with dynamic XML requests?

Answer:

  1. Use POST method with Content-Type text/xml.

  2. Insert dynamic variables in XML body:

<GetUserRequest>
    <userId>{{userId}}</userId>
</GetUserRequest>
  1. Parse response using xml2Json in test scripts:

let jsonObj = xml2Json(pm.response.text());
pm.expect(jsonObj.GetUserResponse.status).to.eql("success");

29. How do you implement data-driven testing for multiple scenarios?

Answer:

  • Use CSV or JSON data files with Collection Runner or Newman:

CSV Example:

username,password,expectedStatus
user1,pass1,200
user2,pass2,200
  • Newman command:

newman run collection.json -e environment.json --iteration-data data.csv
  • Validates multiple combinations automatically and generates reports.


30. How do you debug failing tests in CI/CD integration?

Answer:

  1. Use Newman CLI logs with JSON or HTML reporter:

newman run collection.json -e env.json -r cli,json,html
  1. Examine:

    • Request/response details

    • Environment variables

    • Authorization tokens

    • Response time and headers

  2. Add console.log() in test scripts for deeper debugging.


31. How do you handle rate limiting and throttling APIs?

Answer:

  • APIs may return 429 Too Many Requests.

  • Handle using:

    • Delays in Collection Runner (--delay-request 500).

    • Check response headers X-RateLimit-Remaining and Retry-After.

    • Retry logic in pre-request scripts.


32. How do you manage large Postman collections efficiently?

Answer:

  • Organize requests into folders by module/functionality.

  • Use collection and environment variables for shared data.

  • Maintain modular pre-request and test scripts.

  • Use naming conventions and tags for easy navigation.


33. How do you test negative scenarios effectively in Postman?

Answer:

  • Send invalid/missing data.

  • Validate API error codes and messages:

pm.test("Invalid email returns 400", function() {
    pm.response.to.have.status(400);
    pm.expect(pm.response.text()).to.include("Invalid email");
});
  • Ensures API handles errors gracefully and consistently.


34. How do you monitor APIs in production using Postman Monitors?

Answer:

  • Monitors run collections at scheduled intervals.

  • Use Cases:

    • Monitor uptime and availability.

    • Validate response time and schema.

    • Send alerts for failures (email/webhook).

  • Steps:

    1. Select collection → Create Monitor → Choose schedule.

    2. Set environment → Monitor executes automatically.

    3. Analyze logs and reports for performance issues.


35. Explain best practices for advanced Postman usage.

Answer:

  1. Use modular scripts for reusable code.

  2. Maintain consistent naming conventions for requests, variables, and collections.

  3. Use environment variables for dynamic data and different stages.

  4. Use Newman for CI/CD automation and reporting.

  5. Validate JSON/XML schemas for consistent responses.

  6. Implement data-driven testing with CSV/JSON.

  7. Organize large collections with folders, tags, and versioning.

  8. Use Monitors for production health checks.

  9. Document collections clearly for team collaboration..


36. How do you handle API versioning in Postman?

Answer:

  • Maintain separate collections for each API version (v1, v2, v3).

  • Use environment variables to switch base URLs easily:

{{baseUrl}}/v1/users
{{baseUrl}}/v2/users
  • Benefits:

    • Easy regression testing for new versions.

    • Maintain backward compatibility checks.

  • Advanced Tip: Tag requests with version numbers for better organization.


37. How do you use collection-level scripts in Postman?

Answer:

  • Postman allows pre-request and test scripts at collection level, which apply to all requests in that collection.

  • Use Case:

    • Automatically add authentication tokens to all requests.

    • Log start/end time for performance measurement.

  • Example (pre-request script at collection level):

pm.request.headers.add({ key: "Authorization", value: "Bearer " + pm.environment.get("authToken") });

38. How do you perform security testing in Postman?

Answer:

  1. Authentication: Validate all endpoints require proper credentials.

  2. Authorization: Ensure users cannot access restricted endpoints.

  3. Token Expiry: Check that expired tokens return correct error codes.

  4. Input Validation: Test SQL injection, XSS, and invalid data.

  5. Headers: Validate secure headers like Content-Security-Policy.

  6. Cookies: Ensure secure flags (HttpOnly, Secure) are set.

Example script to check authorization:

pm.test("Unauthorized request returns 401", function () {
    pm.response.to.have.status(401);
});

39. How do you debug intermittent API failures in Postman?

Answer:

  • Enable Postman Console for logging requests and responses.

  • Add console.log() in pre-request and test scripts.

  • Validate environment variables and tokens are correct.

  • Check network latency, API rate limits, or server errors.

  • Use Newman reports in CI/CD pipelines for historical failures.

  • Consider mock servers to isolate issues.


40. How do you perform end-to-end workflow testing with Postman?

Answer:

  • Combine multiple requests in a collection representing the workflow.

  • Example: User Registration → Login → Create Resource → Update Resource → Delete Resource.

  • Use environment variables to pass dynamic data between requests.

  • Validate each step using test scripts.

pm.environment.set("userId", pm.response.json().id);
  • Run using Collection Runner or Newman for automation.


41. How do you validate dynamic JSON responses in Postman?

Answer:

  • Parse JSON using pm.response.json().

  • Use JavaScript logic to validate dynamic data:

let jsonData = pm.response.json();
pm.test("Check age is greater than 18", function() {
    pm.expect(jsonData.age).to.be.above(18);
});
pm.test("Name matches pattern", function() {
    pm.expect(jsonData.name).to.match(/^[A-Za-z]+$/);
});

42. How do you perform batch API testing in Postman?

Answer:

  • Use Collection Runner with multiple iterations.

  • Use data files (CSV/JSON) to feed different payloads.

  • Example: Test 100 user registrations with different emails and passwords.

  • Combine with Newman for CLI execution in pipelines:

newman run users_collection.json -e env.json --iteration-data users.csv

43. How do you handle dynamic query parameters in Postman?

Answer:

  • Use environment or collection variables in the URL:

https://api.example.com/users?status={{status}}&role={{role}}
  • Set variable values in environment or pre-request scripts:

pm.environment.set("status", "active");
pm.environment.set("role", "admin");
  • Dynamic parameters allow testing multiple query combinations without changing the request manually.


44. How do you test GraphQL mutations in Postman?

Answer:

  • Select POST method → GraphQL body.

  • Example mutation:

mutation createUser($input: UserInput!) {
  createUser(input: $input) {
    id
    name
    email
  }
}
  • Variables JSON:

{
  "input": {
    "name": "John",
    "email": "john@example.com"
  }
}
  • Validate response using test scripts:

pm.test("User created successfully", function () {
    let jsonData = pm.response.json();
    pm.expect(jsonData.data.createUser.id).to.not.be.null;
});

45. How do you handle SOAP API testing with dynamic XML and namespaces?

Answer:

  • SOAP APIs require POST requests with XML body.

  • Use environment variables for dynamic fields:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:usr="http://user.example.com">
   <soapenv:Body>
      <usr:GetUser>
         <usr:UserId>{{userId}}</usr:UserId>
      </usr:GetUser>
   </soapenv:Body>
</soapenv:Envelope>
  • Parse response using xml2Json or XPath in test scripts:

let jsonObj = xml2Json(pm.response.text());
pm.expect(jsonObj.GetUserResponse.status).to.eql("Success");

46. How do you implement retry logic for unstable APIs in Postman?

Answer:

  • Use pre-request scripts or Newman CLI options.

  • Example: Retry until status code 200 or max retries reached:

let retryCount = pm.environment.get("retryCount") || 0;
if (pm.response.code !== 200 && retryCount < 3) {
    pm.environment.set("retryCount", retryCount + 1);
    postman.setNextRequest(pm.info.requestName);
} else {
    pm.environment.set("retryCount", 0);
}

47. How do you use Postman for CI/CD reporting in Jenkins or GitHub Actions?

Answer:

  • Run collection using Newman in CLI:

newman run collection.json -e env.json -r cli,html,json
  • Jenkins/GitHub Actions can:

    • Generate HTML/JSON reports.

    • Fail pipeline if tests fail.

    • Notify teams via Slack/email on failures.

  • Use environment variables for dynamic configuration in pipeline.


48. How do you perform negative testing for authorization and authentication?

Answer:

  • Test invalid tokens, expired tokens, missing headers.

  • Validate correct response codes and messages:

pm.test("Unauthorized access returns 401", function() {
    pm.response.to.have.status(401);
});
pm.test("Error message contains 'Invalid token'", function() {
    pm.expect(pm.response.text()).to.include("Invalid token");
});
  • Ensures APIs are secure and handle unauthorized access properly.


49. Best practices for team collaboration in Postman 

Answer:

  1. Use team workspaces for shared collections and environments.

  2. Maintain version-controlled collections in Git.

  3. Use environment variables to avoid hardcoding sensitive data.

  4. Document all requests, scripts, and workflows.

  5. Tag requests for modules or API versions.

  6. Implement monitors to track production API health.

  7. Automate testing with Newman and CI/CD.

  8. Use modular pre-request and test scripts for reusability.