Building Blocks of Postman 🏗️📬
The next topic of the "Related Workflow in Postman" series is Building Blocks of Postman. Here, we will discuss topics like Request, Collection, and Environment.
It is now quicker and easier to design and test APIs in Postman. Postman's most potent and practical aspects, such as requests, collections, and environments, can be easily created with a single click.
Let's take a quick tour of the Building blocks of Postman.
Request 🙏🏻
Any HTTP request can be made using Building blocks in Postman. Click Request and add a title and description to create a request. Choose a collection, then store the Request there. You can choose an existing collection or start a new one. After saving the Request, you can modify it in the builder by adding the URL, method, headers, and body.
Let's check the example screen of Request in Postman.

Collection
A group of different requests is referred to as a Collection, which you can then categorize into folders. Click Collection, give it a name, and a description, then click Create Collection. After building the collection, you can add folders for improved organization and then save requests there.

Environment
You often require various setups while working with APIs, such as your client Machine, the development server, or the production API. Using environments, you can modify requests. Click Environment and assign a name to it to build an environment. The variables you want to save as key-value pairs should then be added.

Extraction of an authentication token
Our next topic in the "Related Workflow in Postman" series is the Extraction of an authentication token. Here, we will discuss how to extract a token from a login response.
We can extract the value of an authentication token from a login response body and pass in subsequent requests as 'Bearer Token' using the below commands:
According to the authentication server's response:
{ "accessToken": "foo", "refreshToken": "bar" "expires": "1234" }
The syntax for extracting the token value from the Tests tab is:
var jsonData = pm.response.json();
var token = jsonData.accessToken;
We can set the token as a variable for future use by using:
pm.globals.set('token', token);
The following needs to be provided to the headers part (see the key: value example below) in order to use the token in the new request:
Authorization:Bearer {{token}}
Reading Links from Response 🧐
Our next topic in the "Related Workflow in Postman" series is the Reading links from the response. Here, we will discuss the topic along with codes.
At first, we have to give the sample links to the server for response. Syntax of the same is shown below:
{
"links": [
"http://sample.com/1",
"http://sample.com/2",
"http://sample.com/3",
"http://sample.com/4",
"http://sample.com/5"
]
}
To read the response, we have to follow the below points:
- Parse the response
- Check the response
- Iterate over the response
Now, let's understand all the steps using code:
// Parsing the response
var jsonData = pm.response.json();
// Checking the response
pm.test("Response containing the links", function () {
pm.response.to.have.status(210);
pm.expect(jsonData.links).to.be.an('array').that.is.not.empty;
});
// Iterating over the response
var links = jsonData.links;
links.forEach(function(link) {
pm.test("Status code is 404", function () {
pm.sendRequest(link, function (err, res) {
pm.expect(res).to.have.property('code', 404);
});
});
});
Using the pm.sendRequest command, we have read the response, iterated over the links arrays, and submitted the request for each link.
Parameterize Requests in Postman
Our last topic in the "Related Workflow in Postman" series is the Parameterize requests in Postman. Here, we will discuss the topics in steps.
Postman requests can be parameterized so that they can be executed with a variety of data sets. Variables and parameters are used to do this. The URL contains a parameter that is used to deliver additional data to the server.
Follow the below steps to parameterize requests:
Step 1: In the top right corner, click on the eye icon of the Environment dropdown in the Postman app.

Step 2: In the Global Section, Click on the Edit link.

Step 3: MANAGE ENVIRONMENTS pop-up appears. In the VARIABLE box, type URL, and in the INITIAL VALUE field, you can type any URL. For example, https://www.codingninjas.com. Then select Save.

Step 4: To move to the next screen, Click on Close. You can also change the Tab.
Step 5: Enter {{url}}/index.htm in the address bar of Http Request tab. Select the GET method and click the Send button.

Response
Once a request has been sent, the response will have the response code 200 OK filled in. This denotes a fulfilled request and the right endpoint.

Frequently Asked Questions
What is setNextRequest in Postman?
The source of your collection run is Postman's setNextRequest() scope. Any request, such as those inside folders, can be set as the next request when a collection is run in its entirety. If you run a folder, only that folder is the postman.setNextRequest() function's scope.
What is Newman in Postman?
For Postman, Newman is a command-line Collection Runner. You can use the command line to execute and test a Postman Collection directly. It is designed to be extensible so that you can integrate it with your build systems and continuous integration servers.
Why do we need Newman?
Running a group of tests directly from the command line is simple with Newman. This makes it simple to run Postman tests on systems without a GUI and enables us to run a set of Postman tests directly from most build tools.
Conclusion
We have discussed the topic of Related Workflow in Postman. We have seen topics like API, Building Blocks of Postman, Extraction of an authentication token, Reading links from the response, and Parameterize Requests in Postman.
We hope this blog has helped you enhance your knowledge of "Related Workflow in Postman." If you want to learn more, check out our articles API Testing, Introduction to Postman, Postman to API Testing, and many more on our platform Coding Ninjas Studio.
But suppose you have just started your learning process and are looking for questions from tech giants like Amazon, Microsoft, Uber, etc. In that case, you must look at the problems, interview experiences, and interview bundles for placement preparations.
However, you may consider our paid courses to give your career an edge over others!
Happy Learning!