Lesson 34 of 158 – Postman GET Request
34%

Postman GET Request

A GET request is used to retrieve or read data from a server. In Postman, we can easily send a GET request to an API and view the response.

Note: GET requests are commonly used when a mobile application needs to retrieve data such as students, products, users, courses, or profiles.

1. What is a GET Request?

A GET request is an HTTP request used to retrieve information from a server.

For example:

GET /students

This request asks the server to return student information.

2. GET Request in Postman

Postman provides an easy interface for sending GET requests.

The basic process is:

  1. Select GET
  2. Enter the API URL
  3. Click Send
  4. Read the response

3. Create a New Request

Open Postman and create a new HTTP request.

You will see a method dropdown, URL field, and a Send button.

These controls are used to send API requests to the server.

4. Select GET Method

Click the HTTP method dropdown and select GET.

GET tells the server that we want to retrieve information.

GET

5. Enter the API URL

Enter the URL of the API that you want to test.

Example:

http://localhost/api/students.php

The URL identifies the API endpoint that will process the request.

6. Example Student API

Suppose our PHP API provides a student endpoint:

http://localhost/api/students.php

We can send a GET request to retrieve the student records.

7. Click Send

After selecting GET and entering the URL, click the Send button.

Postman sends the request to the API server.

8. Server Processes the Request

The server receives the GET request and processes it.

For a PHP API, the PHP file may connect to MySQL and retrieve records.

GET Request
     ↓
PHP API
     ↓
MySQL Database
     ↓
JSON Response

9. GET Response

After processing the request, the server sends a response back to Postman.

The response may contain JSON data.

[
    {
        "id": 1,
        "name": "Rahul"
    }
]

10. Status Code 200 OK

A successful GET request commonly returns the HTTP status code:

200 OK

This means the server successfully processed the request.

11. Viewing JSON Response

Postman displays the API response in the response section.

If the API returns JSON, Postman formats the JSON so that it is easier to read.

{
    "id": 1,
    "name": "Amit",
    "course": "ADCA"
}

12. GET Request Without Request Body

A normal GET request usually does not require a request body.

The required information can be provided through the URL or query parameters.

GET http://localhost/api/students.php

13. GET Request and Query Parameters

Query parameters can be used to send additional information with a GET request.

Example:

http://localhost/api/students.php?course=ADCA

Here, course=ADCA is a query parameter.

14. GET Request for One Student

A GET endpoint can also retrieve a specific record.

Example:

http://localhost/api/student.php?id=10

The API can use the ID to find the requested student.

15. GET Request and Headers

A GET request can also contain HTTP headers.

For example:

Accept: application/json

The Accept header can indicate that the client expects JSON data.

16. Add Accept Header in Postman

In Postman, open the Headers section.

Add:

Key: Accept
Value: application/json

Now the request contains an Accept header.

17. GET Request with Headers

A GET request can contain both a URL and headers.

GET
http://localhost/api/students.php

Accept: application/json

The server receives both the request URL and the headers.

18. Reading the Response Status

After clicking Send, check the response status in Postman.

Common successful response:

200 OK

The status code helps us understand whether the request was successful.

19. GET Request Response Time

Postman also displays the response time.

Response time tells us approximately how long the server took to respond.

For example:

200 OK
125 ms

20. GET Request Response Size

Postman can also display the size of the response.

A response containing many records may be larger than a response containing only one record.

200 OK
125 ms
2.4 KB

21. GET Request Error

A GET request may fail for several reasons.

  • Incorrect URL
  • Server is not running
  • API file does not exist
  • Database error
  • Invalid parameters

22. 404 Not Found

If the requested API endpoint does not exist, the server may return:

404 Not Found

Check the URL carefully when you receive a 404 response.

23. 500 Internal Server Error

A PHP API may return a server error when there is a problem in the backend.

500 Internal Server Error

For example, the PHP code may contain an error or the database connection may fail.

24. GET Request and React Native

React Native applications commonly use GET requests to retrieve data from a REST API.

Example flow:

React Native App
       ↓
GET Request
       ↓
PHP REST API
       ↓
MySQL Database
       ↓
JSON Response
       ↓
React Native App

25. GET Request for Student List

Suppose a mobile application needs to display all students.

The application can request:

GET /api/students.php

The API can return a list of students in JSON format.

26. GET Request Checklist

Before sending a GET request, check:

  • GET method is selected
  • API URL is correct
  • Server is running
  • API endpoint exists
  • Query parameters are correct if required
  • Required headers are present

27. Complete GET Request Flow

1. Open Postman
2. Create a request
3. Select GET
4. Enter API URL
5. Add headers if required
6. Click Send
7. Check status code
8. Read JSON response

This is the basic workflow for testing a GET API in Postman.

28. Example Complete GET Request

Method:

GET

URL:

http://localhost/api/students.php

Header:

Accept: application/json

Click Send to test the API.

29. Example JSON Response

A successful API might return:

[
    {
        "id": 1,
        "name": "Rahul",
        "course": "ADCA"
    },
    {
        "id": 2,
        "name": "Priya",
        "course": "Web Development"
    }
]

This data can later be displayed inside a React Native application.

30. Postman GET Request Summary

A GET request is one of the most important requests when working with REST APIs. It is primarily used to retrieve data from a server.

In Postman, select GET, enter the API URL, optionally add headers or query parameters, click Send, and then inspect the response.

GET
   ↓
API Endpoint
   ↓
Server
   ↓
Database
   ↓
JSON Response

📌 Key Points

  • GET is used to retrieve data.
  • Postman can be used to test GET APIs.
  • A GET request usually does not require a request body.
  • Query parameters can be added to a GET URL.
  • Headers can be added when required.
  • 200 OK commonly indicates a successful request.
  • 404 indicates that the requested resource was not found.
  • 500 indicates a server-side error.
  • GET APIs commonly return JSON data.
  • React Native applications can use GET APIs to retrieve data.

🧠 Quick Quiz

Question: Which HTTP method is commonly used to retrieve data from an API?