Collections

 

Collections

Objectives

  • What a Collection is
  • How to create a Collection in POSTman
  • Learn how to use Set as variable in POSTman
  • How to manage Variables

Let’s say you want to save a request because you want to reuse it at a later point. All you have to do is hit on the Save button. See screenshot below:

A new window should pop up.

Make sure that your Request name is something you easily remember and is related to the actual request that you’re making with the API. You may notice that the Save button is disabled. That’s because saving a request requires you to create a Collection.

A collection is basically a list of multiple requests that are typically connected to the same API. So if you’re working with multiple APIs, you’ll probably will have a collection for each individual API.

On the Save Request window, click on the Create Collection button (You may need to scroll down) and name your collection to Todos API and then just simply click on the check mark that appears. And then finally, click the Save to Todos API button to save your request in your newly created collection.

If you close the tab, you should be able to find the saved request by clicking on the Collections > Todos API (expanded) > Get All Todos. See screenshot below:

The tab that contains the saved request should open up and you should be able to run the same request again.

Set as Variable

Typically, you don’t want to have the address on the request input box. Address might change later on and you don’t want to update every single URL that you saved.

To set an address as a variable, simply highlight the address in the request box and click the Set as variable button that will appear:

Click Set as a new variable and just name this variable to whatever you want. In my case I named it baseUrl:

It should also ask you for Scope. There are different scopes available in Postman where you can save this variable, but for this example, we are just going to use the Todos API collection as scope. Then click Set variable.

Finally, click on Save to save this request again (now with baseUrl variable as the variable for our jsonplaceholder URL)

To Edit This Variable

1. Under Collections, click Todos API (You should see three dots when you hover over Todos API). Click on the three dots icon and choose Edit

2. Click the Variables tab

3. You will then be able to see the baseUrl variable. To update the URL of baseUrl, just change the CURRENT VALUE and then just click on the Save button again.

Exporting a Collection

You can export your collections from Postman by selecting the ... next to the collection, then Export. You can then select the format you'd like your collection to export as. Click Export to download your newly generated JSON file.

Sharing a Collection

You can share your collection by selecting the ... next to the collection, then Share Collection. Developers can share a collection in three ways:

  1. Sharing to a workspace
  2. Sharing via the Embed 
  3. Sharing with a public link

In this example, let's try sharing with a Public Link. It will then show a generate public link button. Click on that button and then just copy the generated link and share it with your co-developers.



Next