API Response Structure in Postman
Last Updated :
24 Jan, 2024
Postman, a widely-used API testing tool, is essential for developers to interact with APIs efficiently. Understanding the API response structure in Postman is key to successful testing and debugging. From status codes to response body options, Postman provides a user-friendly interface for analyzing and interpreting API responses.
API Response Structure in Postman
Let's talk about the way the API response is visualized in Postman. Firstly, we have status codes, time section, and size are present.
Response structure example1. Status Code
In the above response structure example, you can see on the right that "200 OK" means the status code.
- The status information is available to us, in our case it is "200".
- Postman also gives us detailed information about what "200" means in general, so this will be helpful in case you encounter a status code that you are not aware of. Along with that we also get a string description of the status code. Here "200" means "ok".
2. Time
The "524ms" represents time section.
- This is time taken by the server to respond to the request sent by the postman. If we click on that, we can see detailed breakdown of the time taken for different events right from the socket initialization to the downloading of the response and the total time taken this analysis can be helpful in primary performance testing of any API.
3. Size
The next time, size is present ("1.89 KB" in the image).
- It shows the size of request and response and the breakdown of size of each component of request and response. This can be helpful in preliminary analysis of the request and response.
4. Body
- The body section is nothing where our actual response is displayed.
- We can see different options available to view the body.
- That are Pretty, Raw, Preview, and Visualize.
You can see in the below image we have Pretty, Raw, and Preview sections.
Body sectionPretty:
- It displays information in a visually appealing way. Different colors for keys (e.g., ID) and values enhance readability.
- It is primarily used for JSON data, where the response is formatted with colored syntax.
- It allows collapsing of individual items or the entire response for easier interaction.
- It allows collapsing of individual items or the entire response for easier interaction.
- It provides a user-friendly view, making it easy to understand the structure of the data.
As you can see in the below pic, the key colors(id, category, ..) are different and the values colors(coffee, true, ..) are different.
Overview of preview sectionRaw:
- It displays data in its raw format, without any formatting or color.
- It shows raw JSON, making it challenging to read due to lack of visual structure.
- It is necessary for understanding the true, unformatted representation of the data.
Overview of raw sectionPreview:
- Postman attempts to preview data in a user-friendly manner, such as images or other formats it can handle.
- It is primarily beneficial for data types other than JSON (e.g., HTML).
- It attempts to display non-JSON data with different colors for enhanced readability.
Overview of preview sectionVisualize:
Visualize section is helpful when we have add some test scripts and also add some graphics to visualize our test. Since, we do not have any test scripts right now for this request, this section is empty.
Visualize section5. Cookies
Cookies are the small files that are sent from the web server to clients (example: Browser). They store necessary information.
Example: One of the cookies use case shopping website, when we add items to the cart, if you close the browser logged in or logged out. It is the cookie files that stores that particular information( i.e. the items are still added to the cart). This is all possible because cookie files that are being sent from server to client are save in your computer and once you access this browser again on that particular website you can able to fetch the items you have added previously.
- Postman allows you to manage the cookies for the domain. You can: Add, edit and delete the cookie.
- In header, set cookie has been returned in response from the server to basically set this particular cookie.
So, cookie header is basically used to send cookie from the client and Set-Cookie is the key, that is used to set the cookie that are returned by the server and then this cookie gets saved in the cookies section of the postman.
If we have any cookies those will be visible here.
Cookies Section example
Header section when cookies are present6. Response Headers
The example response header is mentioned below:
Response header example- The response headers are displayed in tabular format.
- The "i" symbol in circle that is next to header provides extra information about that header to understand what that particular header means.
- In the above headers example, you can see content-type, which here indicates resource media type and its value is application JSON.
7. Test Results
It is an important feature of postman that allows us to write test scripts that will run on the response that we received from the server. Tests in Postman are Javascript code that is executed after receiving response.
Example of writing a basic test:
- Starts with pm.test
- First parameter: name of the test
- Second parameter: A function that contains assertions like pm response status
Test Results Section exampleIn the above example, the executed example tests are shown.
Conclusion
The Postman API response structure provides a comprehensive view of the interaction between a client and a server. From status codes and response times to various ways of visualizing the response body, it offers essential tools for developers and testers. This structured approach simplifies the debugging process and enhances the overall efficiency of API testing and development workflows.
Similar Reads
Structure of HTTP request in Postman
Postman is a powerful tool that simplifies the process of making HTTP requests for testing APIs. Understanding the structure of a typical HTTP request in Postman is fundamental for everyone who want to test endpoints. In this article, we'll break down the key components of an HTTP request in Postman
3 min read
Response in Postman
Postman, a popular API testing tool, plays a crucial role in helping developers interact with APIs seamlessly. It serves as an essential tool for efficient testing and debugging. With its user-friendly interface, Postman simplifies the analysis of responses, providing insights into various aspects s
8 min read
What is API Testing in Postman ?
APIs, or Application Programming Interfaces, have become the backbone of modern software development, facilitating communication and data transfer between various systems and applications. This article delves into the concept of API testing, a critical component in the software development lifecycle
6 min read
Create and Send API Requests in Postman
Postman serves as a flexible tool, simplifying the system of crafting and checking out API requests. In the world of software, APIs(Application Programming Interfaces) are the constructing blocks for packages to speak with each other. In this article, you will find out how Postman turns into your go
4 min read
How to save Request & Response result as a File in Postman?
In this article, we will see how to save request & response results as a file in Postman. It is a collaborative API development platform used to design, develop, test, document, and manage APIs efficiently. Saving requests and responses as files documents API interactions, making it helpful for
2 min read
Send Get request in Postman
Postman is a well-known tool for doing Manual API Testing. It has lots of features and at the beginner level, it is used for testing the HTTP responses like GET, POST, PUT, and DELETE. In this article, we will discuss how to deal with Get requests in Postman. What is GET Request?This is an HTTP requ
3 min read
How to Use Postman Online for API Testing
Postman is a popular form for testing and is active among APIs, whether you're a planner or an exploratory. Postman Online, as known or named at another time or place, is a variant of Postman that runs in your network internet or web viewing software, assigning you API testing and cooperation tasks
7 min read
Navigating API Testing with Postman
API(Application Programming Interface) testing plays a pivotal role in the software development lifecycle, ensuring the seamless functionality of APIs and safeguarding against potential issues. Postman, a comprehensive API development and testing tool, offers a range of features to streamline and en
6 min read
Automating API Testing with Postman
Testing the functionality, dependability, and performance of an API is known as API testing. API testing can be done automatically or manually. The technique of automating the execution of API tests with tools is known as automated API testing. This can save time and effort, as well as ensure that A
5 min read
Postman vs Apidog for API Testing
API testing is the practice of ensuring that an API works as intended. It can be conducted manually by developers or automated using an API testing tool. There are several sorts of API testing, and each one serves a unique role in guaranteeing the API's reliability. In this article, we'll learn abou
5 min read