Table of contents
1.
Introduction
2.
About Postman📭
3.
Receiving responses
4.
Response body
4.1.
The Pretty view
4.2.
The Raw view
4.3.
The Preview view
4.4.
The Visualise view
5.
Cookies
6.
Headers
6.1.
Test results
7.
Network information in postman
7.1.
SSL verification errors
8.
Response code
9.
Response time
10.
Response size
11.
Saving responses in Postman
12.
Frequently Asked Questions✍️
12.1.
What is Postman?
12.2.
What is a response in Postman?
12.3.
How can we view multiple pieces of information from the response of the postman?
13.
Conclusion🗒️
Last Updated: Mar 27, 2024

What to do with the received responses in Postman?

Author Manish Kumar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Hey Ninja! Today we will be learning what to do with the received responses in Postman. Postman is a computer application which we use for API testing. So grab your coffee as we learn what to do with the received responses in Postman. 

What to do with the received responses in Postman

About Postman📭

Postman lets us write scripts that runs before or after we receive a response from the server. These scripts are so flexible that we can do practically anything in them. The Postman object is empowered to interact with the central theme of Postman.

Postman has a sandbox where we can run our prerequisite and test scripts. This opens up several new possibilities. Like extracting values from the response and saving them inside a global or an environment variable. Global and environment variables let us keep track of everything that affects the state of the APIs. Some examples of standard variables we can use with an API are user IDs and session tokens.

We follow the following flow while working with variables:

  1. Send a request from Postman.
  2. Receive the response and copy a value from the response body or the header of the response.
  3. Go to Environment Manager.
  4. Put the variable value.
  5. Click submit.

 

This works but becomes a bit complex if we have too many variables. Test scripts dramatically simplify this flow. In test scripts, we call the postman.setEnvironmentVariable(key, value) or postman.setGlobalVariable(key, value) to set a variable with values we have extracted from the response. 

Receiving responses

The Postman response viewer helps you visualise and check API responses' correctness. The API response is made up of the response body, headers, and the HTTP status code. Let's look at them all one by one.

Response body

The Postman body tab gives us several tools to help us understand the response quickly. We can display the body in one of these four views: Pretty, Raw, Preview, and Visualise.

Let's see how we can find items in the responses. So we can use any one of the two ways. Either we can select the search iconSearch icon in the results pane, or if we like to use keyboard shortcuts, then we can simply use ⌘+F(in macOS) or Ctrl+F (in Windows OS). 

Here, we should note that whenever the Content-Type header of the response indicates that the answer is an image, Postman will automatically detect and render the picture. So, we have received the response. Let's see all the available views of the Postman that helps us to decide what to do with the received responses in postman.

The Pretty view

The Pretty view modifies JSON or XML responses, making them easier to view. Links inside the Pretty view are highlighted, and selecting them can load a GET request in Postman with the link URL.

For navigating significant responses, we select the down arrows next to a line to collapse large sections of the reaction.

Pretty View

 

Forcing JSON formatting in Pretty view: Postman automatically formats the body if the response has the appropriate Content-Type header. If we receive a reply with a different Content-Type header, we can force formatting through JSON. We can do so by:

  1. Select the settings icon Settings icon.
  2. Then, select Settings in the General tab,
  3. At last, select JSON from the Language detection dropdown.

The Raw view

The Raw view is a significant text area with the response body. It can indicate whether our response is minified. It is a simple view so we can move on to the next view, i.e., Preview.

Raw View

 

The Preview view

The Preview view displays the response in a sandboxed iframe. An iframe is used to view a page within a page by default. Some web frameworks return HTML errors by default, and Preview proves to be handy in those cases. Images and JavaScript are turned off in the iframe due to iframe sandbox restrictions. To save the response locally, we can select "Send and download" for binary response types. We can then view it using the appropriate viewer. This allows us to test audio files, PDFs, zip files, or any other file types the API returns.

Preview View

 

Having seen what could be done in Preview, let us look at the last view type.

The Visualise view

The Visualise view displays the data in the API response according to the visualisation code we add to the requests Tests. Please refer to Visualising answers to learn how to add, use, and debug visualisation code.

Visualise view

 

The response body also consists of cookies which are discussed below.

Cookies

We can inspect cookies dispatched by the server in the Cookies tab. A cookie's entry mentions its name, value, the associated domain and path, and related information about the cookie.

Headers

Key-value pairs under the Headers tab indicate the header. If we want details of the header, we can hover over the information icon Information icon next to the header name to get a description. The information received is as per the HTTP specification. If we send a HEAD request, Postman will show the Headers tab by default instead of the Body tab.

Test results

Test Results tab would display the results if the API request  we are looking at had any test scripts.

Network information in postman

Postman displays network information when our API returns a response. We hover over the network iconNetwork information icon to get the local and remote IP addresses for the request we sent.

When we make an https request, the network icon includes a padlock. When we hover over the icon, the network information will show additional information, including certificate verification details.

Network Information

 

SSL verification errors

If SSL verification is enabled in Postman's global settings and the verification fails, the response area displays an error message. We can select the link in the error message to turn off verification globally and immediately rerun the request.

If SSL is turned off globally, but we turn it on for our request, Postman displays the error and gives us a link to open the console.

SSL verification errors

 

 

If we select Disable SSL Verification in the error message, we will need to turn it back on if we want to verify certificates for future requests. Select the settings icon Settings icon in the header and Settings to enable it globally. In the General tab, select SSL certificate verification.

Select the Settings tab in the request to enable SSL verification for only the current proposal, and then select Enable SSL certificate verification.

If SSL verification is turned off and our request returns a certificate verification error, we can hover over the network information for details about the error.

Details of error

 

The console displays a warning for requests that return data successfully but with a certificate verification failure.

Response code

Postman displays the response code returned by the API. Please hover over the response code briefly to describe it and its meaning.

Response

 

Some API responses contain custom messages that can help you understand response codes. For example, if we receive a 401 Unauthorised response, the message might advise us to check the token we used in the request. We will display messages in the response body if the returned messages are customised.

Response time

The response takes some time to arrive from the server. Postman automatically calculates this time in milliseconds. This information can be helpful in some preliminary performance testing. We can hover over the response time to view a comparative graph of time taken by different processes.

Response Time

 

Response size

Postman also displays the approximate size of the response. Hover over the response size to get a breakdown by body and header sizes.

Saving responses in Postman

We can save responses if a request has been preserved in a collection. Once the response has been returned, we select Save Response.

  • We may select Save as an example to save the response as an example we can access later.
  • Select Save to a file to save the response as a JSON file.

Frequently Asked Questions✍️

What is Postman?

It is a computer application that is used for API testing. It sends an API request to the web server and receives the response. We don’t have to do any extra work, or any setting up of framework is required while we send and receive requests. 

What is a response in Postman?

Generally, the response depends on the request. We receive many requests containing various responses, and we must get helpful information from these responses.  Postman has got a fantastic interface for receiving responses which is also user-friendly.

How can we view multiple pieces of information from the response of the postman?

Postman offers us a user-friendly interface that aids in displaying multiple segments of information from all the responses in a significant way. This simplifies our thinking on what to do with the received responses in postman. The interface provides multiple options.

Conclusion🗒️

This post gave you a brief overview of what to do with the received responses in postman. You learned various implementing techniques and best practices. I hope you loved reading our blog on 'What to do with the received responses in postman'.

Here are some articles which will aid your learning about 'What to do with the received responses in postman'.

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem DesignMachine learning, and many more! 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 problemsinterview experiences, and interview bundle for placement preparations.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blog on What to do with the received responses in postman if you find it helpful and engaging!

Happy Learning!!

Thank You

 

Live masterclass