Top Postman Interview Questions and Answers

This section covers a broad range of Postman interview questions, focusing on its features, functionalities, and use in API testing and development.

What is Postman?

Postman is a popular API development and testing platform. It's a free and easy-to-use tool for making HTTP requests, testing APIs, managing API collections, and collaborating with teams. It has both a desktop application and a web application.

Postman's Origin

Postman started as a Chrome extension and now has native applications for Windows and macOS.

Reasons for Using Postman

Postman is widely used for its:

  • Free access.
  • Ease of use (sending various HTTP requests).
  • Large and active community support.
  • Extensibility (through its API).
  • Support for various API types (REST, SOAP).
  • Integration with CI/CD (Continuous Integration/Continuous Delivery) tools.
  • Cloud capabilities for teamwork.

What is an API?

An API (Application Programming Interface) is a set of rules and specifications that software programs can use to communicate and interact with each other. APIs define how one software component should request services from and provide data to another.

Postman Authorization Methods

Postman supports many authentication and authorization methods:

  • API Key
  • OAuth 1.0/2.0
  • Bearer Token
  • Basic Auth
  • Digest Auth
  • Hawk Authentication
  • AWS Signature
  • NTLM Authentication

Collections in Postman

Collections in Postman group related API requests into folders for better organization and management. This allows you to structure your API tests efficiently.

API Testing Tools

Other popular API testing tools include:

  • SoapUI
  • Katalon Studio
  • Tricentis Tosca
  • Apigee
  • JMeter

Accessing Postman Variables

Access variables using double curly braces:

Types of API Requests in Postman

Postman supports various HTTP methods:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
  • And many others...

HTTP Requests

An HTTP request is a message sent from a client to a server to request a resource. It includes the HTTP method, URI (Uniform Resource Identifier), HTTP version, headers, and optionally, a request body.

Components of an HTTP Request

  • Method (verb): GET, POST, PUT, DELETE, etc.
  • URI: Specifies the resource.
  • HTTP Version: (e.g., HTTP/1.1).
  • Headers: Metadata (content type, authorization, etc.).
  • Body (Payload): Data sent to the server.

Why Base64 Encoding for Authorization?

Base64 encoding converts binary data into an ASCII string. It's often used for transmitting credentials (username and password) in HTTP headers because it's easily handled by web browsers.

Components of an HTTP Response

  • Status Code: (e.g., 200 OK, 404 Not Found).
  • HTTP Version: (e.g., HTTP/1.1).
  • Headers: Metadata (content type, etc.).
  • Body: The response data.

Environments in Postman

Environments store key-value pairs used to manage settings (like URLs or API keys) for different testing environments (development, staging, production).

Duplicate Global Variables in Postman

You cannot have duplicate global variables with the same name. Local variables with the same name are allowed in different environments. Local variables take precedence over global variables if names are duplicated.

Logging Variable Values

JavaScript Code

console.log(pm.environment.get("myVariable"));

Postman Monitors

Postman Monitors automate API testing by repeatedly running collections at scheduled intervals.

Team Workspaces

Team workspaces enable collaboration on API development and testing. Team members can share collections, environments, and other resources.

Query Params vs. Path Variables

Query parameters: Used for filtering and sorting. Added to the URL after a question mark (?). Path parameters: Part of the URI that identifies a specific resource. Appear directly in the URL path.

Postman Collection Runner

The collection runner automates running multiple requests within a collection, allowing you to perform data-driven testing.

Basic Auth

Basic Auth sends username and password in the HTTP header (Base64 encoded).

Importing Variables into Postman Monitors

You can import local environment variables, but global variables are not supported in Postman Monitors.

Limitations of Postman

  • Can struggle with very large numbers of requests.
  • Managing large projects can be challenging.
  • Limited code-based workspace management.

Binary Forms in POST Requests

Binary forms are used for sending non-textual data (files, images) in POST requests.

Postman Cloud

Postman Cloud is a collaborative platform allowing teams to share and manage their API collections and testing environments. This is useful for team-based projects.

Digest Auth in Postman

Digest authentication is a more secure alternative to basic authentication. It involves a multi-step process where the client and server exchange information to generate a hash used for authentication.

Saving Work in Postman Cloud

While Postman Cloud offers collaboration features, it's generally recommended to use a team workspace instead of directly saving sensitive company data to the Postman cloud to help prevent security breaches.

HTTP Status Code: 201 (Created)

A 201 (Created) status code indicates that a new resource has been successfully created on the server (typically in response to a POST request).

Removing Local Variables

Local variables in Postman are automatically removed after the request completes.

Saving API Responses to Files

  1. Click the download icon in the response section.
  2. (Alternative) Click the dropdown arrow next to the send button; choose the download option.

HTTP Status Code: 304 (Not Modified)

A 304 (Not Modified) response indicates that a resource hasn't changed since the last request, avoiding unnecessary data transfer.

HTTP Status Code: 301 (Moved Permanently)

A 301 (Moved Permanently) response indicates that a resource has permanently moved to a new URL. Search engines use this information to update their indexes.

Organizing Requests in Postman

Use Postman Collections to group related API requests into folders for better organization.

Postman Variable Scopes

Postman offers various variable scopes:

  • Global: Available across the entire workspace.
  • Local: Available only within a specific request or script.
  • Environment: Specific to a named environment (development, testing, production).
  • Collection: Specific to a collection.
  • Data: Imported from external data files (JSON, CSV).

Form Data vs. x-www-form-urlencoded

Form data: Sends data as multipart/form-data (suitable for files). x-www-form-urlencoded: Sends data as a URL-encoded string (key-value pairs).

Choosing Variable Scopes

  • Global Variables: General-purpose variables; useful for prototyping.
  • Collection Variables: Constants or settings specific to a collection.
  • Local Variables: Temporary variables specific to a single request.

Accessing Request History in Postman

The History tab shows previously sent requests. You can view, save, and manage these requests from there.

Stopping Request Execution

JavaScript Code

pm.setNextRequest(null);

Reusing Authentication Tokens

Assign the token to a collection. Requests within that collection will inherit it via the "Inherit auth from parent" option.

Query Parameters in GET Requests

Query parameters are appended to the URL after a question mark (?).

Execution Order in Collection Runs

Pre-request scripts (at the request level) are executed first.

Accessing Postman Variables

Access variables using double curly braces:

Running Postman Collections in Jenkins

Use Newman (a command-line collection runner).

Common Postman Status Codes

[Describe the meaning of the status codes 200, 201, 204, 400, 401, and 404.]

Postman Scratch Pad

The Scratchpad allows for offline testing and development of requests and collections.

Postman Request Methods

[List common HTTP request methods (GET, POST, PUT, DELETE, PATCH, etc.).]

Iterating Requests in Postman

Use the Postman Collection Runner to iterate requests with different data sets.

JavaScript Libraries in Postman

[List examples of JavaScript libraries available in Postman (Lodash, Moment.js, etc.).]

GUID (Globally Unique Identifier)

A GUID is a unique identifier, often used to generate unique IDs for resources in APIs.

Example

let guid = uuidv4(); // Using a library like uuid

Postman Test Scripting Language

JavaScript is used for writing tests in Postman.

Generating Random Numbers in Postman

[Provide a JavaScript example to generate random numbers within a given range in Postman.]

Viewing Logs in Postman

Use the Postman Console to view request and response logs.

Binary Forms in Postman

Binary forms send non-textual data (files) in POST requests.

Binary Forms in POST Requests

In Postman, the binary form is used to send non-textual data (files, images, etc.) as part of an HTTP POST request. The data is transmitted in its raw binary format.

Organizing Requests with Collections

Postman collections group related API requests, improving organization and simplifying test management.

Recommended Testing Approach in Postman

While Postman allows for testing using JavaScript, a functional testing approach is generally recommended. Functional tests focus on verifying the functionality of APIs, independent of implementation details, leading to more maintainable and reliable tests. Although Javascript support is still available, functional testing is considered best practice.