The objective of this tutorial is to create a GET request in Postman and learn how to execute it.
Table of Contents
What is GET Request?
A GET request is one of the HTTP methods used to request data from a specified resource. When you enter a URL into your web browser and hit Enter, your browser sends a GET request to the server, asking for the content located at that URL. Here are some real-life examples of GET requests:
- Browsing a Website: When you open a webpage in your browser, your browser sends a GET request to the server hosting that webpage to retrieve the HTML, CSS, and JavaScript files needed to display the page.
- Search Engine Query: When you use a search engine like Google and type in a search query, your browser sends a GET request to the search engine's server, which then responds with the search results page.
- API Calls: Many APIs (Application Programming Interfaces) use GET requests to retrieve data. For instance, a weather API might have a URL like https://api.weather.com/data/temperature?location=NewYork where a GET request to this URL would return the current temperature in New York.
- Fetching Images: When you load a webpage with images, each image is typically fetched using a GET request. For example, <img src="https://example.com/image.jpg"> triggers a GET request to retrieve the image file.
- Accessing Documents: When you click on a link to download a PDF or any other document, your browser sends a GET request to fetch the file from the server.
Here's a simplified example of a GET request:
Let's say you have a simple website that stores information about books. Each book has a unique ID, and you want to retrieve the details of a book with ID 123. You might have an API endpoint like this:
https://restful-booker.herokuapp.com/booking/
Implementation Steps
Make a collection
Please follow this post to learn how to create a Collection in Postman
Make a request to the Collection
Step 1: To create a new request, click on “Add a request” if it is a new Collection. Otherwise, click on the 3 dots and select “Add request”.
Step 2: Once you create a new request, then you will get the following window:
Step 1: Enter the “name” in the request. Here, the name is “GET Booking List”.
Step 2: Enter the “URL” in the address bar.Step 3: Now, select the “GET” request from the list of request methods. Step 4: Press the “Send” button.
Ensure that the Response has been validated
A response from the server will be received once you press the send button.
Status
You can check the status code. Here, we got the status code 200, which means we got a successful response to the request.
Body
In the Body tab of the response box, we have multiple options to see the response in a different format.
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 above example, we have a JSON code file.
Below are the various format types present in Postman.
XML
HTML
Congratulations on finishing this tutorial and I hope you found it helpful! Happy learning!