Skip to content

How To Use Postman Chrome

API Testing Blog

Getting Started with Postman

Postman is a powerful tool for testing and interacting with APIs. This guide will walk you through the basics of using Postman in Chrome and show you how to send simple requests, work with headers and bodies, and even automate your testing.

Installing Postman

  1. Download and install Postman: Visit the Postman website (https://www.postman.com/) and download the Postman native app. It’s available for Windows, macOS, and Linux. Postman also offers a web version that you can access directly from your browser (https://web.postman.io/).

  2. Launch Postman: Once installed, launch Postman.

Sending Your First Request

  1. Create a new request: Click the “New” button in the top left corner of the Postman window. This will open a new request tab.

  2. Choose the request type: In the “Method” dropdown, select the HTTP method you want to use. For example, “GET” for retrieving data or “POST” for sending data.

  3. Enter the Request URL: In the “URL” field, enter the complete URL of the API endpoint you want to interact with.

  4. Send the request: Click the “Send” button to execute the request. You’ll see the response in the “Body” tab, along with information like the status code and response headers.

Example:

Let’s say we want to send a GET request to the “https://reqres.in/api/users” endpoint.

Result: Postman will display the response in the “Body” tab, which will be a JSON representing a list of users.

{
"page": 1,
"per_page": 6,
"total": 12,
"total_pages": 2,
"data": [
{
"id": 1,
"first_name": "George",
"last_name": "Bluth",
"avatar": "https://reqres.in/img/faces/1-image.jpg"
},
{
"id": 2,
"first_name": "Janet",
"last_name": "Weaver",
"avatar": "https://reqres.in/img/faces/2-image.jpg"
},
{
"id": 3,
"first_name": "Emma",
"last_name": "Wong",
"avatar": "https://reqres.in/img/faces/3-image.jpg"
},
{
"id": 4,
"first_name": "Eve",
"last_name": "Holt",
"avatar": "https://reqres.in/img/faces/4-image.jpg"
},
{
"id": 5,
"first_name": "Charles",
"last_name": "Morris",
"avatar": "https://reqres.in/img/faces/5-image.jpg"
},
{
"id": 6,
"first_name": "Tracey",
"last_name": "Ramos",
"avatar": "https://reqres.in/img/faces/6-image.jpg"
}
],
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}

Working with Headers and Authorization

Postman allows you to add headers, including authorization headers, to your requests.

  1. Adding Headers: Click on the “Headers” tab in the request.
  2. Enter Key-Value Pairs: Add the header name in the “Key” column and the corresponding value in the “Value” column.
  3. Authorization: To add authorization, click on the “Authorization” tab and select your authorization type (Basic Auth, Bearer Token, etc.).
  4. Enter Credentials: Provide the necessary credentials (username, password, token) for the chosen method.

Example: Accessing a protected API endpoint using a Bearer Token

Sending Data in Request Body

Postman allows you to send data in the request body.

  1. Select Data Type: Choose the data type for your request body (form-data, x-www-form-urlencoded, raw, binary, etc.).
  2. Enter Data: Fill in the data fields based on the chosen type. For example, in the “raw” type, you can enter JSON or XML data.

Example: Sending a POST request to create a new user on the “https://reqres.in/api/users” endpoint

{
"name": "morpheus",
"job": "leader"
}

Using Postman Collections

Postman Collections help you organize and group your requests.

  1. Create a New Collection: Click on “Collections” in the left sidebar and then click on “Create Collection.” Give your collection a name.
  2. Add Requests: Drag and drop requests from the “Requests” tab into your newly created collection.
  3. Add a Description: You can add descriptions to requests within the collection to provide context and clarify the purpose of each request.
  4. Running Collections: You can run individual requests or the entire collection. You can even set up environment variables for different environments (development, testing, production).

Example:

A collection called “User API” with requests for creating, updating, and deleting users.

Automating with Postman Tests

Postman’s testing feature allows you to run tests alongside your API requests to ensure the API behaves as expected.

  1. Add a Test: Click on the “Tests” tab in the request.
  2. Write Tests: Use JavaScript to write test cases. Postman offers helper functions (pm.test, pm.expect, pm.response, etc.) for making assertions and validating responses.

Example: Verifying the status code of a GET request to “https://reqres.in/api/users

pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});

Using Postman for API Documentation

Postman can be used for documenting your APIs.

  1. Create a Document: While in a collection, click on the “Document” tab.
  2. Build a Doc: You can add descriptions and examples for each request in your collection.
  3. Share Documentation: You can share your documentation with others by copying the link to your published documentation.

Example:

You can document your API collection with information like:

  • API Endpoints (a list of all the available endpoints and their descriptions).
  • Parameters (descriptions of all parameters for each endpoint).
  • Request & Response Examples (examples of the request and the corresponding response).

Conclusion

Postman is a powerful and versatile tool for working with APIs. This guide has covered some of the fundamental features of using Postman for testing and interacting with APIs. As you learn more about Postman, you can explore additional features like environments, mock servers, and integrations with other tools. With the knowledge you gain, you can efficiently test, debug, and document your APIs in a robust and organized way.

API Testing Blog