Skip to content
Logo Theodo

5 Tricks to Become a Postman Master

Elias Tounzal4 min read

A postman, or letter carrier (in American English), sometimes colloquially known as a postie, is an employee of a post office or postal service, who delivers mail and parcel post to residences and businesses. Postman is also the name of a powerful graphical HTTP client helpful when working with APIs. I’ll introduce a few tricks to get started with it!

Installation

To install Postman, go to this link and download the right version for the OS you use.

How to do a simple GET?

Launching the app, you should see the following screen:

WhatsApp Image 2018-02-02 at 14.14.14

Click the Request button at the top-left of the modal, and you’ll get on the Save Request screen.

Give it a name, create a collection if you don’t have any, select a collection and save it.

save-my-request

From there, you’ll be able to send a request. For exemple, you can hit the HTTPCat API. Enter the https://http.cat/[status_code] URL in the dedicated tab, with the status code of your choice. Press Send and you’ll see the response just below.

get-request

A first POST with a JSON body

To illustrate how to do a POST request, we are going to hit the https://jsonplaceholder.typicode.com/ URL, on the post route.

So from the same screen, select POST instead of GET, and enter the URL in the dedicated tab.

post-try

The API we’re hitting enables us to send any JSON body, and sends it back in the response, adding it an id. Let’s then send a random object.

Go in the Body tab, check the raw radio button, and make sure that you selected JSON (application/json) on the dropdown on the right.

The body is a JSON object. There are a couple of things we need to be careful of when we write a JSON object, especially when you are used to writing JavaScript. Check here to know the traps not to fall in.

In the end we obtain this kind of POST requests:

post-object

Just press Send and you’ll have the response!

Useful tricks POSTMAN offers

How to share one’s collections

Export them

On the left of your window, you have a list of your collections. Go over one with your mouse cursor, and you’ll see three dots on the bottom-right of it. Click them, then click Export.

export-collection

You’ll get on a modal that asks you to choose the way you want to download your collection. Choose Collection v2, click Export and save it.

v2-download

Import them

To import a collection, click on Import at the top-right of your window, then get in your own files the json you want to import!

import

How to set environnement variables

The typical use case here is when you work with different environments. Let’s say you develop an API which has a production, a staging and a development environments. For each of them, you want to set a Host and a token variable, to be able to authenticate.

Click the wheel on the top-right of your screen, then select Manage Environments.

manage-environments

Click Add.

add-env

You can now give a name to your environment, and set the variables you need. Click Update when this is done.

create-env

You can do this for each one of your environments, then you’ll see them in the Manage Environments tab.

manage-env

Now go back to the main screen, and fill your request with the variables using double curly brackets: {{ }}.

cats

Best way to create a request: copy as curl

Let’s say you want to reproduce a request done on a website. But this request is a very tricky one with, for example, authentication, complicated headers, a big body or a method you don’t really know how to use.

Then the best way to replicate this request is to basically copy the entire request directly from your browser.

Let’s say we want to get the post request of a research on https://giphy.com/. Open the browser development tools (Right click + Inspect on Chrome). Go in the Network tab and filter the requests by POST methods. Right click the one you are interested in, and select Copy as CURL.

post-request

Now, go back to POSTMAN. On the top-left, click Import, and go in the Paste Raw Text tab. Paste what you copied, and press Import.

import-curl

Now Send the request and you’ll have the answer!

Conclusion

If you want to keep going with Postman, you check this article about Postman Cloud, which explains you how to share and document your API.

And actually there were technically only 4 tricks in this article.. If you find any fifth that would fit here, send it to me and I’ll add it!

Liked this article?