Postman is a REST client for testing web services. Available as a standalone application for Windows, MacOS, and Linux and as chrome extension, it is a must-have tool for developers working with Web API.

Weather you are developing a REST API, or if you are developing a client application that consumes data from a web service, Postman can help you to troubleshoot issues, and speed up development.

In this post I will cover some easy features of Postman that can be quickly learned and put into use, and that will be of use when dealing with Web APIs.

Organize request in collections

Postman collections allow us to save the different REST requests in our application, to reuse them again, and again, and to create new requests from existing ones.

We start by creating a new collection to store the requests related to our project . You can think of a collections as of traditional folder inside of which reside a bunch of request.

Create new collection

We can duplicate an existing collection, save it in json format, delete it, etc

Operations over collections

Clicking in “Save as” we can save the request we are working with in a collection. Next time we need to use that request we will not need to type again all the details of the request.

Save collections

To keep our request more organized we can create a folder structure: this feature is particularly useful when work with an elevated number of entry points.

Save a request in a specific collection

Visualize your request in a tree structure

When we “Duplicate” a collection we are creating a copy of an existing request that can be used as base model to create a new, different request.

This way, adding new requests, to the already existing ones in your collection, it is even more faster, and easier.

Duplicate

Bottom line: store your REST request in a organized structure of collections, to save time reusing them, and create new ones more quickly.

Generate code snippets

Another handy feature of postman is that it can be used to generate code, in different programming languages, from the current request.

Generate code form request

Of course, postman will not develop our application for us, but this feature comes in handy when we are having trouble coding a request that from Postman works correctly.

Choose a programming language

Automatically generated code

We can check the Postman generated snippet, compare with our code, and analyze the differences. For example, some time ago I was testing how to make a REST request in Swift in linux; the code I had originally written was returning a four hundred something error, I compared the snippet of Swift code generated by Postman with the one I had designed, and immediately noticed the problem: I had simply forgotten to specify the content-type !!

Learn to use Postman environments

An environment is a set of variables with its corresponding values.

The most clear example of how to use environments is that of a testing/development set up: we start developing our application in a test set up, at some point we start to move development features to a production set up.

The request URL of a testing, an a production environment are different, but we can create a variable to store that URL.We create 2 environments: testing, and production, and for each environment we set the value of the url variable.

Manage environments
Go to Manage Environments
Add environment
Add environments for test and development

development environment

After that every time we want to test in a specific scenario we need only to switch between environments.

Switch between environments

That’s all, thanks for reading :-). If you liked this post, you can follow my blog (click at the follow button at the bottom) to be notified when new posts are written.

Any favorite tricks for Postman that you would like to share? If that is the case you may a leave a comment below. I ‘d love to hear about your views on tools, and ways to speed up Rest development 🙂

Advertisements