API Collections and Test Suites using Postman

Posted By : Harshita Tiwari | 30-Jun-2020


The first step to creating a test suite for the API using Postman is to create a collection.


What is Collection?

A collection is similar to the created folder on your system in which you can save multiple files. In Postman, we can save similar kinds of requests under the collection. When we open that collection we find these requests in one collection as shown in the below Image.


Let’s explain the whole process from creating a collection and running that collection step by step:


Postman offers different types of variables scope. The Global variables are the general-purpose variables and should be mostly avoided and used only for quick prototyping requirements. These variables are available to all requests in the postman console. To work with the global variable, they can be controlled through the postman console as well. There are the steps mentioned so you can set the global variable using these:


Step 1: Go to the collection menu. Select Edit.

Step 2: Go and set variables according to your API Request URL and Update.

Step 3: The other way to set a Global variable is: Go to Setting and add new.

Step 4: Select Globals and add variables to this.



Step 5: Once you save this, you can access these variables by entering the variable name. Here, we can use the Global variables which we have added in the Global variable environment.


How to create a collection using Postman:


Step 1: For creating new collections we need to click on the New Collection button and then enter your collection name as well as the complete description for the collection like which type of requests they contain.




After entering the Description for the collection, enter the create button to create the collection. Now you have your own collection.


Step 2: To enter the requests into the collection you need to click into the Three dots available along with the collection. Once you click on to view more actions you find the option to add Request into your collection.


Step 3: Click on to the Add Request option to add Request into your collection. Add Request Name, Request Description, and click on the Save button to save your Request.



Step 4: Once you save the request you see the screen.

Click on the added API request and It will show on the Request Panel. Enter the Request URL into that, change the method name according to the API type, enter the parameter and also need to select the content type for the API and click on the Save along with Send button.

So Add likewise your other requests into the collection.



Step 5: Now click on the Arrow available on the screen to run the collection. There is a button to Run the collection.





Step 6: Once you click on the Run button collection runner must be open on the screen where you can see your collection environment, Iteration for tests like how many times you want to Run your collection, Delay and data.



Step 7: Click on the Run Collection Button. Now you see the screen where your collection is successfully Run and because of this, API doesn’t have any Test so it’s showing on the screen below on the API Request.



How to Prepare Tests for the API??


Step 1: Create Tests for API Go to your Builder section and select Tests to write down your test script for the API. You can select Test script from the SNIPPETS and edit according to your Test script.




These are the sample Snippet which is mostly using in the script:


To check the status of the API (200. 201)


pm.test("Status code is 200", function () {

pm.response.to.have.status(200, 201);



Used for JSON value check on the Response body.


pm.test("Your test name", function () {

var jsonData = pm.response.json();




Used to check string on Response body

pm.test("Body is correct", function () {



Here I’m mentioning the example of my test script which I have created for the API.


API Response body contains:



"jsonrpc": "2.0",

"id": null,

"result": {

"is_user": "true",

"is_manager": "true",

"login_info": "you are logged in as Manager",


"name": "Administrator",

"email": "[email protected]",

"company_name": "My Company",

"job_position": "Administrator",

"session_id": "1924102d761a39541126yuihbbnhyt567uyghj"



Test Scripts:



Step 2: Run Your API

Step 3: Prepare your Test script according to the API Response. Save

Step 4: Run Your Collection and you will get the screen.



Using these steps you can run API collection as a Test Suite which will ensure that your sample API is working as expected.


A scalable API testing tool,Postman helps users create collections for their API calls. We are a web and mobile application development company with an objective to custom design advanced, streamlined, scalable software solutions for enterprises. With our all in-purchase software development, at Oodles, we provide you with SaaS models for every business size, industry, system, platform, and use cases.  We are an ERP development company with the goal of maximizing the potential of enterprises with next-gen technologies. We integrate services like WFM, SCM, CRM, and HRM, into ERP software to enable businesses to centrally manage their resources. Get in touch with our experts now!


Please remove URL from text

Comment is required

Sending message..
Connect with us