Lesson 31 of 158 – Postman Introduction
31%

Postman Introduction

Postman is a popular API testing tool used to send HTTP requests to APIs and inspect their responses. It is especially useful when developing and testing REST APIs before connecting them to a React Native mobile application.

In this course, we will use Postman to test our PHP and MySQL REST API before integrating it with React Native.

Note: Postman allows you to test GET, POST, PUT, PATCH and DELETE requests without first creating a mobile application.

1. What is Postman?

Postman is an application used for creating, sending, testing and debugging API requests.

For example, instead of opening a React Native application to test an API, you can send the request directly from Postman.


Postman
   ↓
REST API
   ↓
Response

2. Why Use Postman?

Postman makes API development easier because you can test an API independently from the frontend or mobile application.

  • Send API requests.
  • Test HTTP methods.
  • View API responses.
  • Check status codes.
  • Inspect request headers.
  • Test JSON data.
  • Test authentication.
  • Debug API problems.

3. Postman and REST APIs

Postman works very well with REST APIs because REST APIs communicate using HTTP requests and responses.


Postman
   ↓
HTTP Request
   ↓
REST API
   ↓
HTTP Response
   ↓
Postman

You can inspect the complete communication in Postman.

4. Postman and React Native

Postman is not a replacement for React Native. Instead, it can be used to test the backend API before connecting that API to the mobile application.


First:

Postman → REST API

Then:

React Native → REST API

This makes it easier to identify whether a problem is in the API or in the mobile application.

5. What Can We Test with Postman?

Postman can be used to test many parts of a REST API.

Feature Example
GET Get student list
POST Create student
PUT Update student
PATCH Partially update student
DELETE Delete student
Authentication Login and token testing
Headers Authorization and Content-Type

6. Postman Request

A Postman request contains information such as the HTTP method, URL, headers, parameters and optional request body.


GET
https://example.com/api/students

When you click Send, Postman sends the request to the server.

7. Postman Response

After sending a request, Postman displays the response returned by the server.

The response can include:

  • Status code
  • Response time
  • Response headers
  • Response body
  • Cookies

200 OK

{
    "success": true,
    "message": "Students found"
}

8. HTTP Methods in Postman

Postman provides a method selector that allows you to choose the HTTP method for a request.


GET
POST
PUT
PATCH
DELETE

The selected method determines how the request is sent to the API.

9. GET Request in Postman

A GET request is commonly used to retrieve information.


GET /api/students

Example response:


{
    "success": true,
    "data": [
        {
            "id": 1,
            "name": "Rahul"
        }
    ]
}

10. POST Request in Postman

A POST request is commonly used to create new data.


POST /api/students

Example JSON body:


{
    "name": "Rahul",
    "email": "rahul@example.com",
    "course": "React Native"
}

11. PUT Request in Postman

PUT is commonly used to update an existing resource.


PUT /api/students/10

Example body:


{
    "name": "Rahul Kumar",
    "email": "rahul@example.com",
    "course": "React Native"
}

12. PATCH Request in Postman

PATCH is commonly used when only part of an existing resource needs to be updated.


PATCH /api/students/10

Example:


{
    "course": "Full Stack Development"
}

13. DELETE Request in Postman

DELETE is commonly used to remove a resource.


DELETE /api/students/10

Example response:


{
    "success": true,
    "message": "Student deleted successfully"
}

14. Postman URL

Every API request requires a URL identifying the endpoint that should receive the request.


https://example.com/api/students

For a local PHP API, the URL may look like:


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

15. Send Button

After selecting the method and entering the API URL, the Send button sends the request to the server.


Select Method
      ↓
Enter URL
      ↓
Configure Request
      ↓
Click Send
      ↓
View Response

16. Request Headers in Postman

Headers provide additional information about an HTTP request.

Common API headers include:


Content-Type: application/json
Accept: application/json
Authorization: Bearer TOKEN

Headers are configured in the request's Headers section.

17. JSON Body in Postman

When an API expects JSON, Postman can be used to send a JSON request body.


{
    "name": "Amit",
    "email": "amit@example.com",
    "course": "React Native"
}

For a JSON request, the Content-Type should normally indicate application/json.

18. Checking Status Code

Postman displays the HTTP status code returned by the server.

Status Example Meaning
200 Request succeeded
201 Resource created
400 Bad request
401 Authentication required or invalid
404 Resource not found
500 Server error

19. Checking Response Body

The response body contains the data returned by the API.


{
    "success": true,
    "message": "Student found",
    "data": {
        "id": 1,
        "name": "Rahul"
    }
}

Postman displays the response body so that developers can inspect whether the API is returning the expected data.

20. Testing a PHP REST API

Postman is particularly useful for testing a PHP REST API before connecting it to React Native.


Postman
   ↓
PHP REST API
   ↓
MySQL Database
   ↓
PHP Response
   ↓
Postman

This allows you to verify the backend independently.

21. Testing a Student API

Suppose our API endpoint is:


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

We can select GET in Postman and click Send.

The API may return:


{
    "success": true,
    "data": [
        {
            "id": 1,
            "name": "Rahul"
        }
    ]
}

22. Postman and API Debugging

Postman can help identify problems in an API by showing the actual request and response.

For example, if an API returns 400 Bad Request, you can inspect:

  • URL
  • HTTP method
  • Headers
  • Query parameters
  • Request body
  • Response body

23. Postman and Authentication

Postman can also be used to test authenticated APIs.

For example:


Authorization:
Bearer YOUR_JWT_TOKEN

This becomes especially useful when we build JWT authentication for our React Native application.

24. Postman and API Development Workflow


Create API
    ↓
Test API in Postman
    ↓
Fix API Problems
    ↓
Test Again
    ↓
Connect React Native
    ↓
Test Mobile Application

Testing the backend first can make mobile application development easier.

25. Common Postman Mistakes

  • Using the wrong API URL.
  • Selecting the wrong HTTP method.
  • Sending invalid JSON.
  • Forgetting the Content-Type header when required.
  • Using incorrect authorization information.
  • Using the wrong query parameter.
  • Testing the wrong endpoint.
  • Ignoring the HTTP status code.

26. Postman for Mobile App Developers

For React Native developers, Postman is useful for testing the backend before writing the mobile API integration code.

For example:


First:

Postman → GET /api/students

Then:

React Native → GET /api/students

If the API works correctly in Postman, you can use the same endpoint from React Native.

27. Postman Collections

Postman allows API requests to be organized into collections.

For example, a Student API collection can contain:

  • Get Students
  • Get Student
  • Add Student
  • Update Student
  • Delete Student
  • Login
  • Register

Collections make it easier to keep related API requests together.

28. Complete Postman API Flow


Open Postman
      ↓
Create Request
      ↓
Select HTTP Method
      ↓
Enter API URL
      ↓
Add Headers
      ↓
Add Body if Required
      ↓
Click Send
      ↓
Check Status Code
      ↓
Check JSON Response
      ↓
Debug if Required

29. First Student API Test

Suppose your PHP REST API is running at:


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

In Postman:

  1. Select GET.
  2. Enter the API URL.
  3. Click Send.
  4. Check the status code.
  5. Check the response body.

If the API is working correctly, you may receive:


{
    "success": true,
    "message": "Students found",
    "data": []
}

30. Complete Postman Introduction

Postman is an important tool for REST API development. It allows us to test the backend independently before connecting it to a React Native application.


Postman
   ↓
HTTP Request
   ↓
PHP REST API
   ↓
MySQL
   ↓
JSON Response
   ↓
Postman

In the upcoming lessons, we will learn how to install and configure Postman and then create different API requests such as GET, POST, PUT, PATCH and DELETE.

📌 Key Points

  • Postman is used for testing APIs.
  • Postman can send HTTP requests to REST APIs.
  • It supports GET, POST, PUT, PATCH and DELETE requests.
  • You can configure request URLs, headers and bodies.
  • Postman can send JSON request data.
  • Postman displays HTTP status codes.
  • Postman displays response headers and response bodies.
  • It is useful for testing PHP REST APIs.
  • It can be used before connecting an API to React Native.
  • Postman can help debug API problems.
  • Postman can test authentication headers.
  • Postman collections can organize related API requests.
  • Postman can be used to test CRUD APIs.
  • Testing the backend first can simplify mobile API integration.
  • Postman is an important tool for REST API development.

🧠 Quick Quiz

Question: What is the main purpose of Postman in REST API development?