Postman – powerful API testing tool

Postman – powerful API testing tool

postman_poster
Source

During the API creating work, it is necessary to test API calls. We can do this in many ways. One of the good method could be just using browser to enter url in address bar. However using this method we can test only GET requests. Also there is problems with setting up headers.

Other method to test HTTP requests is using cURL format and appropriate software https://curl.haxx.se/download.html. This is a console program, so it is very extensible and powerful. However it is a console program and it is more complicated to use and we should manage request database on our own. It can be easier.

Fortunately it exists a program Postman. It is a software for all kind of HTTP request work. It can be installed as a standalone application and as a Chrome plug in.

Features

Postman has many different features. All of them are related to executing HTTP requests and to manage them. We will try to list it below.

Running HTTP requests

The most basic functionality is executing requests.

postman_request

This view is very simple, but very powerful. Generally, this few buttons gives us a possibility to define request options in many different ways. On above screen we can see a following parameters:

postman_request_marked

  1. Choose HTTP method
  2. Define request address
  3. Defines query parameters (e.g ?id=12)
  4. Execute a HTTP request
  5. Save it in a library
  6. Set Authorization methods and data
  7. Define request headers. We can set up presets with templates of the most useful header combinations (e.g. for authorization or to define request context)
  8. Request body for POST, PUT, etc. request method
  9. Script for testing purpose (before test)
  10. Script for testing

This completes the possibilities of HTTP requests. As a side note, I admit the UX of this solution. This is very self-discoverable and meaningful interface.

Saving requests

Each request can be saved and organized in collections.

postman_collections

We can create a collections for all requests. It helps to organise items by projects or related topics of work.

We can also share defined collections with out team or even as an appendix to API documentation.

Exporting request definitions

However it is not so convenient to define each request manually. It can work for some debugging purpose, because it is not needed to set up many requests. If we want to test more request or we want to work with some bigger system we can use Postman method to obtain these requests.

Importing from Swagger

The first option is to import API definition. Postman supports Swagger, WADL and RAML definition format.

Let’s take a Swagger format for this example. That file defines a methods and parameters that is required for this action.

"paths": {
    "/pets": {
        "get": {
            "description": "Returns all pets from the system that the user has access to",
                "produces": ["application/json"],
                "responses": {
                    "200": {
                        "description": "A list of pets.",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/Pet"
                            }
                        }
                    }
                }
            }
        }
    }
},

We can import it using Import button on the top left corner.

Interceptor

The other method to get a sample HTTP request is to use a Postman Interceptor tool. This is a Chrome extension that works with regular Postman program.

After installing it we should turn it on into Chrome

postman_chrome_interceptor

Then we should enable it in Postman

postman-interceptor_on

When we do this we can capture all request made by our page in Chrome.

postman_interceptor_list

This feature saves us time to manually set all request parameters like headers, authorization or data.

Sign up for free end-to-end testing training

Learn how to create end-to-end tests for your applications from the beginning to mobile testing
Name
Email address

GET YOUR EMAIL UPDATES

Get great contents delivered straight to your inbox everyday, just a click away, Sign Up Now.
Name
Email address