Open In App

Create, Use, and Run Postman Collections

Last Updated : 27 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Postman Collections are a powerful feature that enables users to organize and manage API testing and development. Collections consist of requests, which are APIs with a request and response format. In this article, we study the creation, utilization, and execution of Postman Collections with examples.

Creating a Postman Collection

1. Open Postman

Launch the Postman application.

2. Create a New Collection

  1. Click on the “Collections” tab in the left sidebar.
  2. Click the “New Collection” button.
  3. Enter a name and optional description for your collection.

You can create a new blank collection like this:

creating a blank collection

Creating a blank collection

or Choose a template for the collection like this:

Creating collection from the template Rest API Basics

Creating collection from the template Rest API Basics

Here, we have selected Rest API Basics as the template, and what you see is a loader creating template in progress mode. This is how it looks like once the creation is completed.

file

Collection created using Rest API Basics template

It has by default all the four requests available for you to edit and duplicate to save time.

3. Add Requests to the Collection

  1. Click on your newly created collection.
  2. Click the “Add Request” button.
  3. Enter a name for the request and specify the HTTP method (GET, POST, etc.).
  4. Define the request URL and any necessary parameters.
  5. Click “Save” to add the request to the collection.
file

Adding a new request

Remember to always name your APIs depending on the resource you are accessing, how you are accessing and what action you are going to perform.

In the image show below, we are trying to fetch the user details by userId. So the route pattern is like

<Server_Url>/<resource>/<action>/<any_params>

Every one have their own internal standards or rules behind naming the routes but this is something that is most widely used among the developers in general.

file

Another way to create a request is by using Import button available on top.

Copy the following lines of code and click on import button. Then you will be able to see a dialog that gets opened that says paste cURL. Paste the below code in that text box and wait:

Javascript




--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic QVV2OHJyY19QLUViUDJFMG1wYjQ5QlY3ckZ0M1Vzci12ZFVaTzhWR09ualJlaEdIQlhrU3pjaHIzN1NZRjJHTmRRRllTcDcyamg1UVVoekc6RU1uQVdlMDZpb0d0b3VKczdnTFlUOWNoSzktMmpKLS03TUtSWHBJOEZlc21ZXzJLcC1kXzdhQ3FmZjdNOW1vRUpCdnVYb0JPNGNsS3RZMHY=' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'ignoreCache=true' \
--data-urlencode 'return_authn_schemes=true' \
--data-urlencode 'return_client_metadata=true' \
--data-urlencode 'return_unconsented_scopes=true'


This will create a new request and gives you the rename and save options, once this is successfully processed.

postman

4. Repeat for Additional Requests

Repeat the process to add more requests to the collection if needed.

Using a Postman Collection

1. Access Collections

In the “Collections” tab, you’ll see a list of your collections.

2. View and Edit Requests

  1. Click on a collection to view its requests.
  2. Click on a request to view and edit its details, including the request URL, parameters, headers, etc.

3. Organize and Group

Organize requests within a collection using folders to structure your API tests logically.

Here is the public collection available over postman website showing how to organize APIs by collection and folder level. This serves as a good example for organizing the requests in postman collection

Teams Workspace- using postman collection

Running a Postman Collection

1. Open Collection Runner

Click on the “Runner” tab in the left sidebar.

2. Select Collection

Choose the collection you want to run from the dropdown list.

3. Run Collection

Click the “Run” button to execute all requests in the collection.

You can run all the tests in a folder and all the responses will be visible one by one

Visible Responses

Run all the APIs in the folder

Then, a new view will be visible on the screen as shown below. Here you can choose to run manually or schedule runs at regular intervals.

view showing the multiple options available to run the folder or collection altogether

view showing the multiple options available to run the folder or collection altogether

4. View Results

  1. Postman will execute each request sequentially and display results.
  2. You can view response details, status, headers, and more as shown below.
results

Postman Run folder results view

This is how it looks after all the APIs in the folder has been run

Conclusion

Postman collections are powerful tools for maintaining and automating API testing and development workflows. By creating, using, and running collections, you can streamline your testing process, collaborate with team members. Regularly exploring new features and staying updated on Postman plans ensures optimal utilization of this versatile tool.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads