Response in Postman
Once you send the request, API sends the response. A response is a message the server receives in return for a Request we send. When we send the request, then server accepts that request in and sends back a packet of the requested information, which is called the response. Each response depends on the sent request.
The server responds differently for every request, and it will be good if we take out some info from all of the server responses. It provides a user-friendly interface to see multiple pieces of information from all of the responses easily.
The postman response interface has multiple options. Let’s see these options one by one:
Response Status and Information
Enter the URL www.tutoraspire.com and see the response:
On the top right corner of the response box, we can see the Status, Time, and Size of the code.
Status Code
A status code defines the status of the request. On entering URL, a mistake can be typed in the URL, or there may be a server-side problem. Status code is used to know about what went wrong and where you made a mistake. There are different status codes, and each of the status codes has different meanings.
Let’s see some standard status codes:
200: This code is used for a successful request.
201: For a successful request and data was created.
204: For empty response.
400: This is used for Bad Request. If you enter something wrong or you missed some required parameters, then the request would not be understood by the server, and you will get 400 status code.
401: This is used for Unauthorized Access. If the request authentication failed or the user does not have permissions for the requested operations, then you will get a 401 status code.
403: This is for Forbidden or Access Denied.
404: This will come if the Data Not Found.
405: This will come if the method not allowed or if the requested method is not supported.
500: This code is used for Internal Server Error.
503: And this code is used for Service Unavailable.
Time
Time is the duration between the sent request time and the received response time. Means, this is the duration which the response took after we sent the request and received the response.
This is very useful sometimes because many projects have a Service Level Agreement (SLA). The time shown here is not the actual time that the request will take. It is just approximate time, but you can consider this as an actual time.
Size
Size is the size of the response when it is processed within memory. This response size includes the size of response, cookies, headers, and everything that has been transmitted along with the response.
Response Body
A Response body is the body of the response, which actually contains the response content that has been sent from the server. In this section, you can see the web page code is sent to us as a response.
In this box, there are three ways to see the response in the response body:
- Pretty
- Raw
- Preview
Pretty: As the name specifies, pretty is the prettier way to see the content. In this option, code will colorfully show with different keywords and have indentations in the code, which is useful for reading. Each color has different meanings. This makes the code nicer.
Raw: This is almost similar to pretty but shows the code without colors and in single lines. It is just a raw version of the code without any colorful keywords.
Preview: This will show the preview of the page that has been sent. It has the same page been run inside a browser. You just need to click on the preview, and you will get the exact page as you would have seen inside a browser.
Preview tab renders the response in a sandboxed iframe, and because of iframe sandbox restrictions, JavaScript and images are disabled in the iframe.
Format Type
Each request has a defined response to it as defined by the Content-Type header. That response can be in any format. Such as in the below example we have HTML code file:
You will see that we have multiple format types:
- JSON
- XML
- HTML
- Text
- Auto
Sometimes, the server sends the response in multiple formats. The type of format of response will be visible to its corresponding format type.
Copy Response
From the right-hand side of the response box, you can see two rectangles; that option is used for copying the complete response to the clipboard, which is very useful to send the response to anyone.
Cookies
Cookies are the small size of files which contain the information related to server files or website pages. Once you open the website for the first time, a cookie file will download on your system. This cookie has some information which will be used by the same site when you visit again. This allows the website to give a specific response and specific information according to your last visit.
Postman offers you to see the cookies that have been sent from the server as a response. We cannot make any changes to the cookies since we got from the server.
Try with the URL www.google.com and go to the Cookies section, you will get the cookie.
Headers
Headers are the extra information that is transferred to the server or the client. In the postman, headers will show like key-value pairs under the headers tab.
Once you select Headers option, you will get the following info: