Technology, Tutorials

API Testing and Automation using POSTMAN – Part I

Part 1: Quick introduction of Postman and its basic features

Hello There,

This is a quick tutorial on API automation, documentation and, API monitoring etc using Postman tool. I have split this tutorial into three parts:

1) Part One: Quick introduction of Postman and its basic features.

2) Part Two: Learn API automation & scripts to examine APIs.

3) Part Three: Learn API documentation, mock server, alerts and, monitoring.

What is Postman?

It is a simple tool which to test API instantly.

You can use Postman as a plug-in with Chrome /Firefox or download standalone desktop app from here.

Once you download and open the app; You will see the Postman dashboard click on the New button.

You will see the options as shown in below screenshot, in this tutorial will focus on

  • Environment
  • Request
  • Collection
  • Environment
  • Request: To execute basic API / request.

Steps to execute API?

1] Click on the Request and enter the request name and description (optional).

2] Select the HTTP method GET, POST from the dropdown.

3] Enter the API / endpoint, headers and, body parameters as needed.

4] Click on a send button to execute API.

5] If you have an existing collection select from the list or create a new collection. (Optional)

Once API executes, you can view the response received, status and, total time etc.

Here I have demonstrated the API execution using login API.

  • Collection

The collection is nothing but a group of APIs. We can create project wise or feature wise collection to categories APIs for e.g. authentication collection consolidates user onboarding related APIs.

  • Environment & Variable

Environment is dictionary containing key-value pairs, where key represents variable.

You can have global variables which are available globally or environment variables accessible in the specific environment. To test same API on separate systems rather than creating different APIs to test API payload on different environment namely UAT, production; we can utilise the same API with different environment viz UAT, production and, development; having environment specific variables/entries like domain name, header properties etc.

How to create environment variables:

You can create environment by clicking the gear as shown in the picture below or click on the New button and select Environment option.

You can create environment variables as shown below:

Here I have created UAT, production and development environment with variables URL &header_client_id. I have put the environment specific entries as values here.

Make sure you put same variable name/key in every environment.

How to use Environment variables?

Syntax to call the variable is “{{variableName}}”. Let’s use already created “url” variable in login API to execute API in different environments, we have to use {{url}} in the API. The postman will fetch its value and execute an API.

Now if we choose UAT as an environment, login API will hit on the UAT system and the API would be; and if the development environment is selected.

In the next blog will see how to Automate APIs and monitor them.

Stay Curious & Keep Learning 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *