how to use postman

Mastering Postman: A Step-by-Step Guide

By Joseph Anderson
AD

Postman, a popular API testing tool, is an invaluable asset for developers, testers, and anyone working with APIs. It simplifies complex API testing and provides a user-friendly interface to curl, making it a robust tool for development. So, let's dive in and explore how to use Postman to its full potential.

Postman is available for Windows, Mac, and Linux, and as a web application. For the purpose of this guide, we'll be focusing on the desktop app. Once installed, launch Postman and let's get started.

Setting Up Your Workspace

Postman opens into a clean workspace with three main sections: the top navigation bar, the builder panel on the left, and the preview panel on the right. The center stage is where you'll see your collection, which starts empty.

AD
Get started in Postman | Postman Docs
Get started in Postman | Postman Docs
Postman Tutorial
Postman Tutorial
10 Postman Hacks for Faster API Testing
10 Postman Hacks for Faster API Testing

The first thing you'll want to do is create a new collection. Click on the 'New' button in the top left corner and choose 'Collection'. Name it and click 'Save'. Now, every API request you make will be stored here.

Making Your First API Request

Postman's main feature is its ability to send HTTP requests and view responses. Let's send a simple GET request to a public API like JSONPlaceholder, which provides fake data for testing and prototyping.

Postman API Tutorial – How to Use Postman to Test an API [Full Course]
Postman API Tutorial – How to Use Postman to Test an API [Full Course]
Postman + APIs - Interactive Tutorial — Hands-on Activity! 🛫
Postman + APIs - Interactive Tutorial — Hands-on Activity! 🛫

Constructing the URL

Click on the 'New' button and select 'Request'. In the address bar, type in "https://jsonplaceholder.typicode.com/todos/1". This will be the URL for our first API request.

Now, let's send the request. Click on the 'Send' button, and Postman will send a GET request to this URL. The response will appear in the preview panel on the right.

AD

Including Headers and Body

You can add headers and bodies to your requests using the 'Headers' and 'Body' tabs in the builder panel. For instance, let's add a 'Content-Type' header with the value 'application/json' to indicate we'll be sending JSON data. To add a JSON body, click on the 'Body' tab, select 'raw', and choose 'JSON (application/json)' from the dropdown.

Now, let's add a JSON body to our POST request. Click on the 'POST' method in the top left, then click on the 'Body' tab, and paste in "{"title": "Sample Title", "completed": true}". Send the request, and you should see your JSON data in the response.

Handling Responses

Postman provides insightful prettified and formatted visualizations of your responses. You canpin a response to keep it visible while testing, bin it to get rid of it, or view the raw text by clicking on the 'Code' icon.

AD

Authorization

POSTman supports various authorization types like API Key, Basic Auth, Bearer Token, etc. Let's add a Bearer token header to authenticate our requests. In the 'Headers' tab, add a new header with the key 'Authorization' and the value 'Bearer {token}'. Replace {token} with your actual token.

Now, sending a request should authenticate you based on the provided token. If authentication is successful, your response should provide appropriate data.

Remember, Postman is a tool designed to streamline your workflow and simplify tasks. Keep discovering its features – from test scripts to environment variables, Postman offers a lot more. Happy testing!

AD
AD