Enroll in Selenium Training

Collections in Postman

Till now, we have learnt the terminologies of Postman in-depth and also have made some GET Requests. In the previous tutorials, we mentioned and briefly explained collections. Recall that Collections are a group of requests grouped into one folder. So that we can use them and share them easily. But in this tutorial, we will learn that a Collection is much more than that.

The definition of Collections is confined to a just grouping of requests. But, a grouping of requests can have unparalleled advantages and make the work of a software developer many folds easy. We will now learn how to step by step save a Collection.

You may also go through the recording of the Postman Tutorial where our experts have explained the concepts in depth.

How to create and save collections in Postman?

1.First of all, hit the endpoint http://restapi.demoqa.com/utilities/weatherfull/city/Hyderabad and in the response box change the format to Text to see the result.

Request_ToolsQA_Weather

  1. Now go to Collections Tab and press the icon that says, New Collection.

New_Collection_icon

  1. Write a name of your choice for your first collection and it's description. In the following image you can see I chose the name MyFirstCollection and a simple description.

Naming_Collection_MyFirstCollection

  1. Press Create to create your first collection.

  2. Now, you have your first collection created but it's empty as of now. Press Save button in the side of address bar.

Save_Request

  1. Choose your collection name in the panel as shown in the image. Press Save.

Save_to_my_collection

Now look at the collections tab, you will have the request saved below your collection name.

Request_Saved_To_Collection

You can click on the Meatballs menu in the side of the collection name and you will see some options. We will talk about the following options in this tutorial.

  • Share Collection
  • Export Collection
  • Add Folder to a Collection
  • Duplicate the Collection
  • Remove the collection from workspace
  • Delete the collection
  • Leave a comment on the collection

Share Collection

Share collection option is used to share the collection to other people such as your team members.

Share_Collection_Option

Sharing a collection is very important when you are working in a company or in a team. There are times when developers create a bunch of Postman Requests while developing APIs to test it. You can request developers to share their collections and you get benefits of it. Or even you create a bunch of Postman Requests, save it to a Collections and share it with your team. It is not worth sharing every request one by one. Rather, we share our Collection as a whole to the team members or anyone to whom we want to share through different methods listed below.

For example, if you are a tester and find out some bug, you can save your steps to reproduce in a Collection, and attach the same to the bug for the developer as a proof and to reproduce the issue. For using this option you must be signed into postman. After signing into Postman you get two options to share the collection.

  • Through workspace
  • Sharing through link

Workspace

A workspace is a collaborative environment for a group of users to develop and test APIs. In simpler terms, workspace is the project in which you work. A setting done in a workspace remains in the same workspace. It is like a shell in which you work. There has to be a workspace to work in Postman, you cannot work isolated. There are two types of workspaces inside Postman

  1. Team Workspace : To use the option of Team workspace your company or you must have purchased the Postman Pro version or else this feature won't work. In Team workspace option, your team can test API simultaneously on one workspace and anyone can edit and update (with permissions). This comes handy when teams are located in different locations or different buildings also. Once edited, everyone's API is updated automatically. There can be any number of Team workspaces.
  2. Personal Workspace : A personal workspace is similar to the team workspace but the difference being this workspace is completely personal to the user who created it. Postman will have no contribution in updating it at any machine, if present.Collections present in the personal workspace is shared through link which is detailed below.

Individuals can organize their work in personal workspaces and teams can collaborate in team workspaces. When you start Postman, you are already inside personal workspace as shown.

My_Workspace_Header

You can create unlimited personal workspace which will be personal to your machine and can test any number of API.

Share Collection through a link

Second option is by creating a link and sending it to the people of your team. This link will be of Postman Cloud. So, your collection will be first uploaded to Postman cloud and then anyone can access it through that link. But, this feature is not recommended while working in a company sometimes because the APIs are personal and companies would not want them to be in other clouds which is not safe.

Export Collections in Postman

Export feature is used to export the collection as a whole by saving it to your computer and which can be later share with the team over the Email in a zip file. Or it can also be shared over a network sharing.

Export_Collection

Follow these steps to learn about exporting the collection.

1.Click on export as shown in the above image.

2.You will see two or three options (depending on your version of Postman). For this tutorial we are using Postman ver 6.0.10. We will choose the option Collection v2.1 and press Export.

Collection_v2.1

This will open the box to save the collection in JSON format on your computer wherever you want. Then this JSON file can be shared with your teammates by any means just like a file.

Add Folder

Collections also let you make folders inside your collection and then save the requests inside your folders. This can further help you to sub-categorize the requests. For example, in the previous chapters we took the example of movies folder to explain collection where you can store all your movies. Making a folder is like making another folder inside Movies folder, such as "English Movies" which will contain all the English language movies, but they are still movies. Similarly, here we can make folders inside the collection and store our requests.

1.Choose the option Add Folder.

Add_Folder_Collection

  1. Name your folder and press Create.

Create_Folder_In_Collection

Now you have your folder created but as of now it is empty.

3.Drag the request and drop it on the folder name.

Drag_Drop_Request

This will move your request to your folder and you are all set.

Duplicate

The option Duplicate as the name suggests, duplicates the collection into a new collection. It means when you click on Duplicate, you make another copy of the same collection in the workspace.

1.Click on Duplicate.

Duplicate _Collection

2.You can see the copy in the sidebar underneath the original collection.

Duplicate_Copy_Collection

Remove From Workspace

Remove from workspace option deletes the collection from the workspace that you are working on.

Remove_From_Workspace

If it is a personal workspace then you can delete it by choosing the option whereas if it is a team workspace then you need to have permission for deleting any collection or request from the workspace.

Delete

Delete and remove from workspace option might seem similar but they differ in just one aspect. Remove from workspace deletes the collection from the current workspace but delete option will delete the collection or request from all the workspaces wherever it is present. Needless to say, you need permissions for this.

Leaving a comment on the collections in Postman

It is quite obvious that when we work in teams, our workspace faces a lot of edit. This can be anything from editing a simple request to editing one test in that request. Now, since you need to apprise everyone what you did, Postman brings you the comment feature. Through this feature you can leave comments in the collection so that everyone can know what you just uploaded in a chronological order.

For this press the arrow button beside the collection name

Options_Collection

Select View in Web from the options

View_In_Web

This will open the collection in your browser. This can be seen by everyone working in the same workspace. Select comments on this page.

Comment_Collection

This will show you the popup to enter the comments.

We will learn in the next section how to import collection in Postman.

How to Import Collections in Postman

If we can export our collection then needless to say it must be imported in some other Postman. So, like export we have another option import but that does not reside inside the meatball menu. The import collection is a part of header as shown below.

Import_Header

Importing a collection is easy in Postman. When you click on import you will see the import panel in front of you.

import panel

Here, as you can see there are different methods that can be used to import a collection. These methods are

  • Importing through drag and drop method
  • Importing the folder
  • Importing through link
  • Pasting the raw text

Importing through drag and drop

Importing through drag and drop is pretty simple. It works the same as the upload feature in many websites such as Google Drive. If you have a collection file in you system just click on that file and drag it to this panel and release the mouse (or drop the file). This way the file/collection will be automatically uploaded in your Postman.

Importing the folder

Importing the folder is same as the previous option just the difference being, in the previous one we were uploading single collection but in this one we can upload multiple collections all at once. Just make a folder inside your system and paste or export many collections in it. When you import the same folder in your Postman, you will see all the Collections being uploaded. If you already have any of the collection from that folder, you will be asked to replace it or form a copy of it.

Importing through link

As we discussed in the previous tutorials, when we work in teams, we often use the Postman cloud or Team workspace which provide us the link to the collection so that everyone can use it without any problem. So importing through a link is the same feature. We can provide link of the same collection in the box and the collection will be imported.

Pasting the raw text

In the above image, the first line in the panel tells us what files can be imported in Postman. There are many files apart from a collection like curl or RAML etc. These files can be imported through raw text coding like in curl file. Although this feature is out of the scope of this course, therefore we won't be discussing it in detail.

You might wonder about the collection runner which we introduced earlier which is used to run the collection requests all at once. We will talk about it after concluding "Tests" topic. It will make more sense in the next tutorial.

Practice Exercise

Since we have come so far in Postman, it would be better if you try out some scenarios yourself.

  1. Create a collection named PracticeExercises.
  2. Create a folder inside the collection and name it Post Requests
  3. Inside the folder save the request which was used in the last chapter (POST Request) only after getting correct response.
  4. Save the collection inside your computer as a JSON file.
Environment Variables in Postman
Environment Variables in Postman
Previous Article
Collection Runner and Writing Test in Postman
Collection Runner and Writing Test in Postman
Next Article
Harish Rajora
I am a computer science engineer. I love to keep growing as the technological world grows. I feel there is no powerful tool than a computer to change the world in any way. Apart from my field of study, I like reading books a lot and developing new stuff.
Reviewers
Lakshay Sharma's Photo
Lakshay Sharma

Similar Articles

Feedback