Hitting API GET Requests with Postman
Welcome you all to the brand new ‘API Testing’ blog series! In the previous blog, we had learnt how to setup Postman. In this tutorial, we will learn how to hit a GET request using Postman!! So let us begin!!!
1. What you will Learn in this blog ?
- Quick glance of workspace
- Hit GET request using Postman
- Brief understanding of response data output
- Brief understanding of Response Headers
- Brief understanding of Request Headers
- Send query parameter as part of GET request
- Add query parameter in the ‘Params’ section
- Remove query parameter from the ‘Params’ section
- History of Requests
- Save the API calls
- Create Collection of GET Requests
2. Quick glance of workspace
Let us open postman app and sign-in (in case you signed out in the previous blog). We can see the new workspace ‘Postman WS’ that we had created in our last blog
![Image 1](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-1-4-300x114.jpg)
To create a new tab, click + icon as shown below
![Image 2](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-2-4-300x157.jpg)
A new tab ‘Untitled GET Request’ gets created
![Image 3](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-3-4-300x115.jpg)
Also notice below that ‘GET’ is default method in the dropdown
![Image 4](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-4-4.jpg)
If you click this dropdown, you would see other HTTP methods as well (example, POST, DELETE etc)
![Image 5](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-5-4-189x300.jpg)
We use the address bar to enter the URI that we would like to hit
![Image 6](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-6-4-300x146.jpg)
To submit the request, we have to click the ‘Send’ button
![Image 7](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-7-4-300x177.jpg)
3. Hit GET request using Postman
We will now see how to hit a GET request using Postman. Let us enter the URI https://httpbin.org in the request url field
![Image 8](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-8-4-300x70.jpg)
Click Send button.
Notice below that we get the response data output (response body) from the server
![Image 9](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-9-4-300x291.jpg)
4. Brief understanding of response data output
By default, response data is of type HTML as shown below
![Image 10](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-10-4-300x195.jpg)
We can also see the status code 200 since the GET request is successfully processed by the server and the server was able to send us the response
![Image 11](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-11-4-300x48.jpg)
As seen below, we can also see the total processing time of the API request alongwith the categorization of the processing time (example, Socket initialization took 62.22 ms and so on)
![Image 12](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-12-4-300x218.jpg)
Next, see below diagram. We can see the size of data which is being transferred as part of this request viz we can see the size of ‘Response’ body/headers. This is the resource size which server sends back as a response
![Image 13](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-13-4-293x300.jpg)
We can also see the size of ‘Request’ headers as can be seen above.
Click ‘Preview’. This tab shows the page preview as shown below
![Image 14](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-14-4-274x300.jpg)
Click ‘Raw’. This section shows the data in raw format
![Image 15](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-15-4-300x187.jpg)
We generally use ‘Pretty’ format as shown below
![Image 16](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-16-3-300x186.jpg)
In the Pretty format, we can see the data in HTML, JSON, XML etc formats
![Image 17](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-17-2-300x167.jpg)
5. Brief understanding of Response Headers
The below diagram shows the ‘Headers’ of the response, example the ‘Date’ the request was created, content-type of the request which is text/html etc
![Image 18](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-18-2-300x141.jpg)
6. Brief understanding of Request Headers
We know that some headers are automatically sent as part of request that we send to the server.
See below, we can see 7 hidden headers that are being sent as part of the GET request
![Image 19](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-19-2-300x180.jpg)
Let us click ‘7 hidden’ to see the request headers, example User-Agent etc
![Image 20](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-20-1-300x168.jpg)
Let us copy the below URI
![Image 21](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-21-1-300x66.jpg)
Open the browser and launch the above URI, see below
![Image 22](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-22-1-205x300.jpg)
We can see ‘HTTP Methods’ section as seen above.
Let us click ‘HTTP Methods’. We can see various methods listed as can be seen below
![Image 23](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-23-1-300x275.jpg)
Let us click GET method and expand its description. Notice below that we see a /get method that we can use in our query
![Image 24](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-24-1-300x123.jpg)
Let us go to the postman, open a new tab and append the /get method to our GET request
![Image 25](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-25-1-300x55.jpg)
Click ‘Send’ to hit this request. The response of the GET request is as below. We can see arguments (which are currently zero), headers, url etc
![Image 26](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-26-1-251x300.jpg)
7. Send query parameter as part of GET request
Let us now send some dummy query parameter as part of GET request. We have studied in previous blog that the query parameter starts with ?
Let the append the dummy query parameter ?dummyparam=TestUser1
![Image 27](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-27-1-300x41.jpg)
Hit Send. Notice below that we are getting the parameter as an argument in the response body
![Image 28](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-28-1-300x164.jpg)
Let us append another query parameter as part of the request
![Image 29](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-29-1-300x26.jpg)
Click Send. Notice now that we are getting both the parameters as an argument in the response body
![Image 30](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-30-1-300x158.jpg)
Also see below. Whatever query parameters we are sending as part of request, the same parameters get automatically created in the ‘Params’ section
![Image 31](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-31-1-300x120.jpg)
8. Add query parameter in the ‘Params’ section
The vice versa is also true. Let us add the 3rd query parameter in the ‘Params’ section as shown below
![Image 32](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-32-300x134.jpg)
Notice that this 3rd query parameter gets automatically appended to the request URI
![Image 33](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-33-300x17.jpg)
Hit Send and notice the expected output shown below
![Image 34](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-34-300x162.jpg)
So this way, we can add the query parameters in the ‘Params’ section as well.
This way, we can test our API manually with different sets of query parameters.
9. Remove query parameter from the ‘Params’ section
We can easily remove the query parameters by de-selecting the checkbox in the ‘Params’ section.
Let us de-select dummyparam2
![Image 35](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-35.jpg)
Notice that dummyparam2 gets automatically removed from the URI as well
![Image 36](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-36-300x32.jpg)
Click Send. Notice the response output. The dummyparam2 is not a part of arguments
![Image 37](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-37-300x158.jpg)
10. History of Requests
We can see all the requests that we have executed in the ‘History’ section, see below. We can execute any of these if we want to
![Image 38](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-38-247x300.jpg)
11. Save the API calls
The red colored small circles means that the API request has not yet been saved
![Image 39](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-39-300x41.jpg)
To save any request, we have to click the ‘Save’ button
![Image 40](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-40-300x78.jpg)
So let us click ‘Save’.
The below window comes up showing the default ‘Request name’
![Image 41](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-41-300x275.jpg)
Let us write some meaningful ‘Request name’, example ‘GETRequestWithQueryParams’
![Image 42](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-42-300x271.jpg)
Notice above that the ‘Save’ button is still disabled. The reason being, this request is not yet part of any collection.
12. Create Collection of GET Requests
Click ‘Create a collection’ button seen in the above figure. The below window would come up
![Image 43](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-43-300x292.jpg)
Enter some meaningful name in the ‘Name your collection’ text field
![Image 44](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-44-300x166.jpg)
Click ‘Create’ button seen next to the collection name text field (see above figure). The below window would come up
![Image 45](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-45-300x203.jpg)
![Image 46](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-46-300x291.jpg)
Now we can see that ‘Save’ button is enabled.
Click ‘Save’. Notice below that red circle is not seen and the request gets saved
![Image 47](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-47.jpg)
We can see our collection in the ‘Collections’ section
![Image 48](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-48-300x127.jpg)
When we expand this collection, we can see our saved request(s)
![Image 49](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-49-300x78.jpg)
Similarly let us save below request
![Image 50](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-50-300x167.jpg)
Let us give some name
![Image 51](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-51-300x290.jpg)
Save.
Notice below that we now have 2 requests saved in a single collection
![Image 52](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-52-300x122.jpg)
We can now click any of the above requests and hit the ‘Send’ button to execute the request.
Below shows execution of ‘GETRequestWithoutParams’ request
![Image 53](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-53-300x122.jpg)
Below shows execution of ‘GETRequestWithQueryParams’ request
![Image 54](https://rahulshettyacademy.com/blog/wp-content/uploads/2022/06/Image-54-300x155.jpg)
So this is how we execute the GET Requests in Postman. In the next blog, we will see how to work with POST requests. We will also see how to chain GET and POST requests.
Thank you for reading!