Browsed by
Category: Tools

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.

Express Profiler – free tool for SQL Server profiling

Express Profiler – free tool for SQL Server profiling

expressProfiler
Source

If we write code working with databases, usually it is beneficial to preview what SQL is used during the system use. It is the most useful when we want to use some ORM like Entity Framework. Each query executed by Entity Framework is transformed into some SQL query, the it is executed on database. Profilers is mostly use to:

  • complexity check of generated SQL query
  • query optimization
  • checking of existence of common querying problems (e.g N+1 problem)

In my current projects I use SQL Server the most often. That’s why one of my favourite tool to profile SQL queries is Express Profiler. It supports all versions of Sql Server Database (also Express).

How to download?

To start using this program we only need to download the proper file and execute given package. You can download it directly from Express Profiler web page: https://expressprofiler.codeplex.com/.

How to use?

If we download this program we can execute it and configure a database inside.

expressProfilerConfig

Application configuration is easy and reduced only to setting a proper database connection information. On screen above you can see 4 fields in configuration:

  • name of DB server
  • type of authentication
  • optionally, user and password

That’s all required configuration. After that, we can just press the “Start trace” button. Then we can get back to testing application and perform some operation, which we want to test.

Tracing

We can notice that Express Profiler window will be getting populated.

expressProfiler_queries

It is a list of queries executed on the database. For each one of this we can see:

  • complete query text
  • database which they are executed on
  • duration
  • number of reads and writes

This is the basic set of information but it gives us a sufficient level of knowledge to investigate what query is executed.

Filtering

That is the main feature of Express Profiler. But it also provide us some help to maintain the systems where it is many queries executed at a single point of time. We can set up a filtering for multiple parameters (e.g. database name, duration or query text.

expressProfiler_filters

This is a very simple tool but very powerful for me. It is also free.