Postman Beginners Guides

Nitin Pathak
6 min readJun 15, 2021

Hello, there today I want to give you a gist of a tool I have been using in my current projects for testing the APIs.

Postman this to me is by far one of the best tools for running API tests and automation if needed.

In the beginning, I used it as any other REST API client, just add in my requests and see a positive response come in but there was so much I could have achieved if only I knew this.

So today I would like you to join me on a short adventure of writing a simple API test with Postman, let’s go!.

STEPS -

  • Install Postman
  • Add Environment Variable

Install Postman :

Installing the Postman app is easy, visit this​ page​ and obtain your platform version (Mac, Windows, Linux).

Add Environment Variable :

Environment variables in Postman aid you when setting up your request, a good example is setting your API URL for re-use in other places. To do this, Open your installed Postman app and click on the Manage Environment button at the top right corner of the window as seen below.

You will be greeted with a popup window. At the bottom right corner, click on the Add button as seen below.

In the next view, you will find a section to enter your environment name, set your variable name, add an initial value, and lastly, a current value, find an example below. To follow this test, you can set your initial value and current value to the URL below.

Initial value:
This is the value shared with your team or publicly when you decide to share your request with others.

Current value:
This is the value used when Postman is making requests using your environment, it is an ephemeral value that does not get saved, only exists locally.

Now Add and exit out of the window, check the Environments drop-down to make sure yours is selected, as seen below.

End To End Flow to Test API Project -

Tools and Technologies:
API Tool:
​ Postman Client (Version: 7.35.0) Scripting:​ JavaScript
Project API:​ Zomato API

This is one of the food delivery app API which can give you the below information as per the documentation I have collected.

They allow the usage limit for the free user for 1000 calls per day to fetch the information they have stored into their database.

As it’s a private API if you want to add (POST), update (PUT) or delete (DELETE) something from the below-given list you need a special kind of authorization permission from them.

Below are the GET Operations they allow with endpoints as of now.

What is API?

An API (Application Programming Interface) is a software intermediary that enables two applications to communicate with each other.

It comprises several subroutine definitions, logs, and tools for creating the application software.

API Test Case Example:

  • End Point
  • URI
  • HTTP Method
  • Body
  • Success Response
  • Failure response
  • Status Code
  • Response Time
  • Comments

What is the procedure to perform API testing?

  1. Choose the suite to add the API test cases
  2. Choose the test development
  3. Demand the development of test cases for the required API methods
  4. Configure the control parameters of the application and then test conditions
  5. Configure method validation
  6. Configure method validation
  7. Execute the API test
  8. Check test reports and filter API test cases
  9. Arrange all API test cases

HTTP Method and Respective CRUD Operation:

How to access API?

  • To access any Client API we need some kind of authorization for the same.
  • We need to obtain the API Key based on our requirement limit.

What is API Key?

An application programming interface key is a unique identifier used to authenticate a user, developer, or calling program to an API.

Now, we need API Key to test the Zomato API as well.

I go to the above link and register myself with the google email account. Hit the given API URL: ​https://developers.zomato.com/api

Click on Generate API Key and Give you Sign up Details, I used Google Account for it​.

It will give you the API Key to use in your testing and development.

API Key- ​8941a2153bcdab81c23075cb28019XXX
Now, I am going to create 5 API Calls on different End Points as below-

https://developers.zomato.com/api/v2.1/categories

https://developers.zomato.com/api/v2.1/cities

https://developers.zomato.com/api/v2.1/locations

https://developers.zomato.com/api/v2.1/restaurant

https://developers.zomato.com/api/v2.1/reviews

For all GET calls we need to pass certain parameters as per API documentation to retrieve the valid result for the same.

https://developers.zomato.com/api/v2.1/categories https://developers.zomato.com/api/v2.1/cities?q=3adba0d9353126e5781e8e49307ba0b1&lat =40.7128&lon=74.006 0&city_ids=280&count=3 https://developers.zomato.com/api/v2.1/locations?query=New%20York&lat=40.7128&lon=74. 0060&count=2 https://developers.zomato.com/api/v2.1/restaurant?res_id=16774318 https://developers.zomato.com/api/v2.1/reviews?res_id=16774318&start=1&count=2

Creating One Collection in Postman for Zomato API testing. What is Collection?

Postman Collections are simply a collection of pre-built requests that can be organized into folders, and they can be easily exported and shared with others.

Test Case01- Verify the authentication scenario by calling API endpoint Invalid API Key.

Expected Result​: It will display Error 403 code with Forbidden Error.

Now add test cases for Response Code and Response Body Text

Response Body data

Test Cases Results-

Test Case 2: Verify that we can search Search for Zomato locations by keyword (New York)

Verification Point:​ Check and verify the city name, Title, status, and Country name. Added Test Cases Now:

Response Data:-

Test Cases Results-

How to run all test cases in one go.?

Open Collection Runner window, I am selecting the ZomatoAPITesting Environment and 10 iterations along with a delay of 5 seconds to check if my results are consistent or not.

Note: You can export the JSON result from the Left Panel and Import it into the MYSQL database to see the tabular report for the same.

Running collections on the command line with Newman

Newman is a command-line Collection Runner for Postman. It allows you to run and test a Postman Collection directly from the command line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.

Newman maintains feature parity with Postman and allows you to run collections the way they are executed inside the collection runner in Postman.

Newman Installation​ — Newman is written in Node.js, make sure​ Node.js is already installed​ on the Jenkins server. Install Newman globally using NPM, which will allow it to be run from anywhere:

Command — npm install -g newman

Now in our Postman, Click on the Postman Collection for which we want to report, Export, and save the postman collection on the local machine.

To generate a report inside our project postman collection folder. We need to use Newman run “Collection Name” -r html
Command — newman run ZomatoAPI testing.postman_collection.json -r htmlextra

Report format:

Thank you for reading this article

Happy Learning
Created By — Nitin Pathak — ​Tech Happily

--

--