API Testing Using Postman

Bisma Latif
7 min readDec 27, 2022
API Testing Using Postman

API testing is one of the most common types of testing any software tester is required to perform. Just as like all the validations and user access are verified on the Front end, it is essential to test that no API allows unrestricted user access.

Since API testing is one of the most common tests you need to perform. I am starting an API testing series using Postman.

In this article, you will learn:

What is API testing?

Postman for API testing

CRUD operations using Postman

API Testing:

API (Application Programming Interface) testing is a type of software testing that involves testing APIs directly and as part of integration testing to determine if they meet expectations for functionality, reliability, performance, and security.

API testing involves testing the API directly using a variety of methods such as sending requests to the API and verifying the response, as well as testing the integration of the API with the application or system it is intended to be used with.

API testing is an important part of the software development process because APIs play a crucial role in the integration of different software systems and the exchange of data between them. Effective API testing helps ensure that the APIs are functioning correctly and reliably and that they meet the performance and security requirements of the system.

Postman for API Testing:

Postman is a tool that allows developers and testers to send HTTP requests and receive responses from HTTP servers. It is commonly used for testing APIs by sending requests and receiving responses to verify that the API is functioning correctly.

Moreover, Postman provides a user-friendly interface that allows you to create and save collections of requests, as well as view and analyze the responses. You can use Postman to send requests using different HTTP methods (such as GET, POST, PUT, and DELETE), and to customize the request by adding headers and parameters.

Apart from including features for testing and debugging APIs, Postman also allows actions such as the ability to set up and run automated tests, view and compare previous responses, and examine the details of the request and response including the HTTP status code and the raw data.

Postman is available as a standalone application that can be installed on your computer, or as a Chrome extension that can be used within the Chrome browser. It is a popular tool among developers and testers for testing APIs and debugging integration issues.

Download & Install Postman:

  1. Navigate to https://www.postman.com/downloads/.
  2. Download the Windows 64-bit file.
  3. Once the .exe file is downloaded, double-click on the downloaded file and complete the installation process.

Note: In case you download the .zip file. Unzip the file and click on the .exe file for installation.

How to Use Postman for API Testing?

Here is how you can use Postman for API testing:

  1. Enter the API endpoint (URL) in the address bar at the top of the Postman window.

2. Select the appropriate HTTP method (e.g. GET, POST, PUT, and DELETE) from the dropdown list next to the address bar.

3. If the API requires any parameters, add them to the “Params” tab in the form of key-value pairs.

4. If the API requires an API key or other authorization, click on the “Authorization” tab and select the appropriate type (e.g. Basic Auth, OAuth2). Then, enter the required credentials.

5. If the API requires a request body (e.g. for POST or PUT requests), click on the “Body” tab and select the appropriate content type (e.g. application/JSON). Then, enter the request body in the appropriate format.

6. Click the “Send” button to send the request to the API.

7. The API’s response will be displayed in the “Response” tab, along with the HTTP status code and any headers.

To get started with Postman, here is how you can perform Basic CRUD operations on the API.

Get Request:

Here is an example of testing an API that returns a list of users:

  1. Set the HTTP method to GET and the endpoint to https://reqres.in/api/users?page=2
  2. Leave the “Params” tab blank, as this API does not require any parameters.
  3. Leave the “Authorization” tab blank, as this API does not require any authorization.
  4. Leave the “Body” tab blank, as this API does not require a request body.
  5. Click the “Send” button to send the request.
  6. The API should return a list of users in the response body, along with an HTTP status code of 200 OK.

POST request:

Here is an example of testing an API that creates a new user:

  1. Set the HTTP method to POST and the endpoint to https://reqres.in/api/users
  2. Leave the “Params” tab blank, as this API does not require any parameters.
  3. Leave the “Authorization” tab blank, as this API does not require any authorization.
  4. Click on the “Body” tab and select the content type “application/JSON”. Add body as:
{
"name": "morpheus",
"job": "leader"
}

5. Click the “Send” button to send the request.

6. The API should return an HTTP status code of 201 Created response, along with a message indicating that the user was created successfully.

Put Request

Here is an example of testing an API that updates an existing user:

  1. Set the HTTP method to PUT and the endpoint to https://reqres.in/api/users/2, where 2 is the ID of the user you want to update.
  2. Leave the “Params” tab blank, as this API does not require any parameters.
  3. Leave the “Authorization” tab blank, as this API does not require any authorization.
  4. Click on the “Body” tab and select the content type “application/JSON”.
  5. Enter the following request body:
{
name": "morpheus",
"job": "zion resident"
}

6. Click the “Send” button to send the request.

7. The API should return an HTTP status code of 200 OK, along with a message indicating that the user was updated successfully.

DELETE request:

Here is an example of testing an API that deletes a current user:

  1. Set the HTTP method to DELETE and the endpoint to https://reqres.in/api/users/2, where 2 is the ID of the user you want to delete.
  2. Leave the “Params” tab blank, as this API does not require any parameters.
  3. Leave the “Authorization” tab blank, as this API does not require any authorization.
  4. Leave the “Body” tab blank, as this API does not require a request body.
  5. Click the “Send” button to send the request.
  6. The API should return an HTTP status code of 204 or 200 OK, along with a message indicating that the user was deleted successfully.

PATCH Request

Here is an example of testing an API that updates a current user using PATCH request:

1. Set the HTTP method to PATCH and the endpoint to https://reqres.in/api/users/2, where 2 is the ID of the user you want to update.

2. Leave the “Params” tab blank, as this API does not require any parameters.

3. Leave the “Authorization” tab blank, as this API does not require any authorization.

4. Click on the “Body” tab and select the content type “application/json”.

5. Enter the following request body:

{
"name": "morpheus",
"job": "zion resident"
}

6. Click the “Send” button to send the request.

7. The API should return an HTTP status code of 200 OK, along with a message indicating that the user was updated successfully.

This is how you can download, install, and run basic CRUD operations on Postman. New articles in the series for authorization, Params, and many more features of Postman will be shared in the next articles.

Till then, happy testing!

--

--

Bisma Latif

A writer, coder, and an avid reader, who puts her soul in everything she does!