Introducing Postman
Postman is a Chrome Add-On and Application which is used to fire requests to an API. It is very lightweight and fast. Requests can be organized in groups, also tests can be created with verifications for certain conditions on the response. With its features it is a very good and convenient API tool. It’s possible to make different kinds of HTTP requests (GET, POST, PUT, PATCH and DELETE). It is possible to add headers in the requests.
In this introduction I will write about more interesting features it has: Variables, Pre-Request Script, Environments and Tests. At the end i will tell you how to share your requests with your teammates.
Variables
There are two types of variables – global and environment. Global variables are for all requests, environment variables are defined per specific environment which can selected from a drop-down or no environment can be selected. Global variables are editable by small eye-shaped icon in the top right corner.
Once defined variables can be used in request with format surrounded by curly brackets: {{VARIABLE_NAME}}. You have autocompletion once you start typing the variable name.
Pre-Request Scripts
Postman allows users to do some JavaScript coding with which to manipulate the data being sent with request. For example, you need to add an encrypted token to your request for authentication, pre-request scripts enable you to do so. It can also be used to change the value of global or environment variables.
Environments
If you need to switch between different credentials this is where environments come in play. By switching environment and with no change in the request you can send different parameters to API. Environments are managed from Settings icon in the top right corner which opens menu with “Manage Environments” link.
Lets say you develop on a local api, you define a {{DOMAIN}} variable for your local environment. In a later stage you need to request a staging api. Instead of duplicate all requests you just copy the local environment and change the value of the {{DOMAIN}} variable. All requests can now fred against diferent apis by switching environment.
Tests
After response is received Postman has functionality to make verifications on it. This is done in “Tests” tab. There are a lot of predefined tests in postman on the right side of the active test tab. Many more can be found at: „https://www.getpostman.com/docs/v6/postman/scripts/test_scripts“
Export/Import
