Google News
logo
Postman Interview Questions
Postman is a free HTTP client-based software application and a collaboration platform for API development. It is mainly used to perform API testing. It is a very popular API client which facilitates developers and providing a platform to design, develop, build, share, text, and document APIs.
 
Postman supports testing of HTTP requests by utilizing GUI (Graphical User Interface), which later we can execute and validate the responses.
 
The Postman tool also facilitates us to send HTTP/s requests to a service and get their responses. We can ensure that the service is up and running by using this.
The Postman tool has become a choice of more than 8 million users. Following are the main reasons for using Postman:
 
It is free : Postman is free software that we can use for API testing. It is free to download and use for teams of any size.

It is easy to use : Postman is an easy-to-use software tool. We can send HTTP requests of various types (such as GET, POST, PUT, PATCH, etc.). We have to download it, and we can send our first request in minutes. It also gives us the ability to save environments for future use.

Community & Support : It has a huge community forum for customer support and extensive documentation.

It is extensible : Postman facilitates us customizing it according to our needs with the Postman API.

APIs Support : It facilitates us to make any API call (REST, SOAP, or plain HTTP) and easily inspect even the largest responses. It also helps manage the end-to-end lifecycle of the API - starting from design to mocking to testing and finally maintaining the APIs.

Runtime Services : Postman provides Runtime Services that help us manage API collections, environments, work-spaces, and different examples.

Integration : Postman facilitates us to easily integrate test suites into our preferred CI/CD tools and services, such as Jenkins with Newman (command-line collection runner).
Postman workspaces are nothing but collaboration areas or space for one or many people to work on the same collection or set of collections. It’s a way to logically separate the collections or requests from each other.
 
In other words, it is simply an abstraction in terms of logical separation of requests.

2 types of Workspaces are supported by Postman i.e. Team, and Personal.
 
1) Team Workspaces are created for collaborating with multiple people that are a part of the same team. Look at it from the perspective of a common shared repository in git, where anyone can pull the repository code and contribute.
 
Similarly, for all the people who are part of the team, the workspace gets shared and everyone can contribute. You can also invite new users to collaborate with your collection by sharing their email id and when someone joins or accepts that invite they will be able to collaborate with that collection.
 
2) Personal Workspaces are a way to logically separate collections (or projects) from one another. These are useful when you are working with multiple projects and you wish to separate the associated requests/collections from each other. then you can create separate workspaces for both the projects.
 
To create a new workspace (either team or personal), simply click the workspace icon and then click “Create New”.
 
Once the workspace properties window opens, select whether you want to create a personal or team workspace. For team workspace, you can choose to invite people with their email addresses by asking them to collaborate on the workspace.
It contains four key elements :
 
HTTP Version : describe HTTP version, for case, HTTP v1.1.

Response Header : Includes information for the HTTP reply message. For example, Content-type, date, status, Content-length and server type.

Status Code : These are response codes issued by a server to a client’s demand.

Response Body : It contains the information that was requested by a customer to the server.
We use base64 chiefly because it transmits the data into the textual appearance and sends it in a more accessible form such as HTML form statistics. Also, we can rely on the identical 64 characters in any programming language that we use.
An HTTP request includes five key elements :
 
* HTTP methods : Set of request methods to perform desired action for a given resource (GET, PUT, POST, DELETE)

* Uniform Resource Identifier (URI) : Describes the resource

* HTTP Version, (example- HTTP v1.1)

* Request Headers, (example- Content-type : application/json, Content-Length : 511)

* Payload : It is basically a Request Body which includes message content.
Postman provides the following API request authorization options :
 
* API Key
* Oauth 1.0
* Oauth 2.0
* Bearer Token
* Basic auth
* Digest auth
* Hawk Authentication
* AWS Signature
* NTLM Authentication
Following is a list of some tools that are used for API Testing :
 
* Postman
* SoapUI
* Katalon Studio
* Tricentis Tosca
* Apigee
* Jmeter etc.
Following is a list of the different types of API requests supported in Postman :
 
* GET
* POST
* PUT
* PATCH
* COPY
* DELETE
* HEAD
* OPTIONS
* LINK
* UNLINK
* PURGE
* LOCK
* UNLOCK
* PROPFIND
* VIEW
10 .
How will you log variable values in Postman?
We can log the variable values in Postman in the console by using the command :
console.log(pm.variables.get("variable_name"));
11 .
How do you access postman variables?
It can be accessed by using the variable name as : {{variable_name}}
12 .
In which type of encoding does postman accept authorization credentials?
Postman accepts Base64 encoding only. This is provided inbuilt in postman or else you can also refer 3rd party websites to convert the credentials in base64.
An environment in postman is a set of key value pairs. You can create multiple environments in postman which can be switched quickly with a press of a button. There are 2 types of environment, global and local.
Since global variables are global i.e. without any environment, global variables cannot have duplicate names. Local variables can have the same name but in different environments.
15 .
Which one will be preferred in postman- a global variable or a local variable?
In postman, if 2 variables have the same name( one being local, other global) then the higher priority is of the local variable. it will overwrite the global variable.
The Postman monitor is used for running collections. Collections run till the specified time defined by the users. It requires the users to be logged in, and the users share the Monitor reports over an email on a daily or monthly basis.
As we know, a workspace is a collaborative environment for users to develop and test APIs. In the same way, a team workspace is a workspace that is shared by the whole team working on the same collections of requests. Usually, it is time-consuming and hard to share the collections through external drives or other sharing; the team workspace synchronizes and collaborates all the team's work in one place.
In Postman, Basic Auth is an authorization technique provided for HTTP user agents like web browsers to enter username and password. After entering the username and password, it gets associated with the request.
Following is the list of key limitations of Postman :
 
* Postman cannot process 1000+ API requests.
* In the case of huge projects, it isn't easy to manage the collections and requests.
* Postman is not suitable for managing the workspace in the form of code. This is because there would be a lot of code duplication for dynamic API requests.
Postman has a command-line integration tool called Newman with which you can run any existing Postman collection.
 
Newman is a nodejs based package, which requires just a node environment to execute the collection and has full parity with the Postman collection runner i.e. the Newman collection runner supports the Postman capabilities like Running assertions, Pre-request scripts or any other scripts that are associated with the requests that are a part of the collection.
 
To use Newman :
 
* You need to have node installed.
* Now the Newman package needs to be installed through npm using the command.
npm install -g newman
* The collection needs to be executed and the associated environment configuration should be first exported to its JSON form through the Postman application
* Now run the below command to run the Postman collection through Newman.
newman run {{path to collection json}} -e {{path to environment json if any}}
Newman uses the concept of reporters and templates to generate HTML reports for the executed collection.
 
Hence, to generate HTML reports, you first need to install a reporter. You can install any of the available HTML reporters like Newman-reporter-html as a node package through the below command.
npm install -g newman-reporter-html
Once the HTML reporter is installed, we can use the Newman command to run the collection with -r flag i.e. the reporter flag and specify the reporter name as HTML.
 
The below command is used :
newman run {{path to collection json}} -e {{path to environment json if any}} -r html
Please note that as we have not mentioned the name or folder where we want the reports to get generated, by default the reports will be generated in a folder named “Newman” that gets created in the same directory where the Newman command is executed from.
Digest Authorization is one of the authorization techniques provided by Postman. In this technique, the client first sends the request to the API and get responses from the server including a number which is usable only once, a realm value and 401 unauthorized response. We will be then sent back an encrypted data array having both username and password along with the data received from the server earlier. The server uses this data to generate an encrypted data string and compares this with what was sent for authenticating the request.
 
We can do this by selecting the Authorization tab, then selecting “Digest Auth” from the drop-down list. Postman window presents the fields for both stages of the authentication request. The fields required for the second stage of the request are auto-filled based on the data received from the server.
The binary form is designed to help send data in a format that is not possible to be entered manually. These options are used while sending large files like images, CSV files, etc in the POST request. Binary representation is the easiest representation for sending complex data with the request.
304 status code stands for NOT MODIFIED. This is used for diminishing the bandwidth of the network in cases of restricted GET requests. In such cases, the response body should be empty or blank and the headers should have a date, location, signature etc.
Postman has the following variable scopes :
 
Global Variables : Global variables allow data access between different collections, requests, and scripts. They are available throughout the workspace.

Environment Variables : These allow us to tailor the requests about different development environments - such as local testing, stage testing, or prod testing.

Local Variables : These are temporary variables that are accessible only within the scope of requests scripts. They are either scoped to a single request or single collection, depending on the requirements. These variables are not available after the completion of the script execution.

Collection Variables : These variables are scoped to be available for all the requests present in a collection. They are independent of the environment.

Data Variables : These variables come from external JSON or CSV files for defining the datasets required to run the collection in Collection Runner or Newman.
Postman collections allow adding pre-request scripts at both the collection as well as individual request level. To add any script that applies to all the requests that are present in the collection, we will need to add a pre-request script at the collection level.
 
Please follow the below steps to add a collection level pre-request script for adding a header to all the requests.
 
a) Open collection options by right-clicking the collection and navigate the pre-request script tab.
b) Now add the below script for adding a request header for all the requests.
pm.request.headers.add({
    key: 'TestHeader',
    value: 'testValue'
});
c) Click Update to save the collection level pre-request script.
 
d) Now execute any request in the collection (directly or through collection runner) and view the request details in the Postman console debugger to validate if the pre-request script is working fine and adding the specified header.

Postman
Workspaces are Postman-provided areas/spaces for teams to collaborate on a specific set of collections. It allows you to logically divide requests or collections exclusive to a developer or team, making request administration accessible.
 
In Postman, there are two sorts of workspaces :
 
* Personal Workspace : These workspaces are essential when working on many projects simultaneously and need logical separation between requests to handle them better.

* Team Workspace : These are designed for group collaboration so that multiple people can participate in testing requests.

By publishing the users' email addresses, we can encourage new users to collaborate on our collections. After accepting the invitation, new users can begin contributing to the workspace by adding or changing requests.
Scratch Pad is a Postman-provided workspace that allows us to operate without relying on Postman servers. It allows you to use some of Postman's capabilities when you're not connected to the internet. The features include creating collections, creating requests, and submitting requests. These are saved locally, and the work is saved into the workspace once you log in.
In Postman, the 301 status code is used to specify that the page has been permanently redirected from one website page to another. It tells the search engine that the old page is outdated, and the search engine has to index the new page URL.
30 .
What is the difference between the form data and x-www-form-urlencoded?
The key difference between the form data and x-www-form-urlencoded is that the URL will be prearranged when sent through x-www-form-urlencoded.
Yes, it is possible to reuse the authentication token for multiple requests. We can achieve it by creating a collection and adding all the requests having the same authentication token to that collection and then assigning the auth token to the same collection. We can apply it to the individual requests by selecting the "Inherit auth from parent" option in the Authorization tab.
Following is the list of most commonly seen status codes in Postman :
 
200 (OK) : Status code 200 specifies that the request was correct.

201 (Created) : Status code 201 specifies that the value wrapped with the request has been created in the database. Here, it is obvious that the request was correct.

204 (No Content) : Status code 204 specifies that the request was correct and received, but there is no content to send. It means there is no response to send to the client by the server.

400 (Bad Request) : Status code 400 specifies a bad request. A bad request means that the syntax of the request was incorrect. It appears when we have sent the wrong parameters along with the request URL or in the request's body.

401 (Unauthorized request) : Status code 401 specifies an unauthorized request. An unauthorized request is a request for which you are not authorized. This status code appears when we are not authorized to access the server or enter the wrong credentials.

404 (Not Found) : Status code 404 specifies that the server was connected, but it could not find what was requested. It simply means "request not found". This status code normally appears when we request a web page not available on the server.
GUID is an acronym that stands for Global Unique Identifier. It is a set of hexadecimal digits separated by hyphens and solves the purpose of uniqueness.
 
In Postman, it is used to generate and send a random value to APIs.
 
Example :
{  
"id": "{{$guid}}",  
} ​
 
In Postman, we can generate random numbers of a given range using some script. Suppose you want to generate numbers between the range of 1 to N, then use the following pre-request script :
pm.globals.set('randomNumber', Math.floor(Math.random()* N));
Now, use this variable in the URL as {{randomNumber}}
Postman monitors are nothing but collection monitors that are set up and are executed as per the configured frequency. These are generally used when someone wants their collection to run at a particular frequency and the results are required to be monitored with failures being notified through email or slack integration.
 
Generally, teams with their infrastructure like CI and own cloud servers would not prefer to use Postman defined monitors as it would run only on published or public endpoints or on mocked endpoints (if configured through mock servers).
A Postman cloud is a centralised location where businesses can access Postman collections. Work can be stored instantaneously in the Postman cloud after logging in. Anyone on the team has access to data and collections from any location.
It is not recommended that you save your work in the Postman cloud since company work cannot be leaked and must remain confidential. If Postman cloud is used, security breaches may occur since Postman cloud requires sign-in. As a result, saving work on Postman Cloud is discouraged, while team workspace is highly encouraged.
38 .
How can we stop executing requests or stop the collection run?
postman.setNextRequest (null);
Here are a few differences between authorization and Authentication :
 
* Authorization is the act of allowing or permitting someone, whereas authentication is proving that something is genuine.
* Authorization always comes first, while authentication comes after authorization.
* Authorization is open to anyone with permission, whereas authentication requires you to have a password.
The Payload of an API Module is the body of your request and response message. When making an API request, it contains the data you send to the server. You can send and receive Payload in various formats, for example, JSON or XML.
Here are the key principles of an API test design :
 
Setup : Create objects, start services, and initialize data.

Execution : Apply API or the scenario, including logging

Verification : It is use for evaluating the result of the execution

Reporting : Indicates Pass, failed, or blocked status

Clean up : Pre-test state
Here are some cons/ disadvantages of using Postman :
 
* Postman cannot process more than 1000 API requests.
* It is not easy to manage the collections and requests in a massive size project.
* Postman is not an ideal API tool for workspace management in the form of code as there can be lots of code duplication while handing the dynamic API requests.
Postman does allow viewing of requests and response parameters in the software application itself. But it is important to see how the request was sent upon applying the pre-request scripts. In such cases, Postman has an additional tool called “Postman Console” which is used for viewing every request and response detail. We can also log the details in the console by using console.log statements in the scripts.
Postman provides a lot of built-in tools and libraries that we can use to add in our pre-request or post-request scripts or test cases. Let us take the example of using the moment.js library. It provides a lot of useful functions to format data around time. Consider that we have a POST request that needs to specify the created date to the user which expects the format “DD/MM/YYYY”.

We can use the moment library to perform this using a single line of code. In our pre-request script, we need to add the below lines of code to get the correctly formatted data and then store that in an environment variable :
var moment = require('moment');
pm.environment.set('createdDate',moment().format('DD/MM/YYYY'));
There are a lot of other useful libraries like crypto.js that are useful for converting text to encrypted values which can further be used anywhere in the request body.