Manage API collections & Version Control through Postman

Tarun Kumar Chatterjee
 
Net – Technology Specialist
August 19, 2020
 
Rate this article
 
Views
2166

There is one recent requirement in my project to find out a way to manage postman PAI collections & keep it up to date by individual team members after every sprint delivery. First, I thought to keep the API collections in GIT repository but later found that Postman itself provide us options to manage the API versions controls & can be shared with team by creating a team workspace. So, I thought to share the detail steps we followed as it may be a common API requirement to many of us.

Let’s first create team workspace named as: Test_API_Collections in Postman

Select Teamwork space we just created & invite team members, we can also drag and drop a .csv or .txt file to bulk invite people. We can specify role so that everyone in team can view and join this workspace as Admin or Collaborator. However, post invitation team members will be able to access the same workspace.

Now, we will create an API Collection & one Get request within it:

Let’s break down version control using the Postman fork and merge feature. In Postman, we can create forks, track and verify changes, be notified of and resolve conflicts, and merge changes. The fork and merge capability simplify version control so we can collaborate and work on different versions of our Postman Collections simultaneously.

Go to parent collection and click the ellipsis (…) and click Create a fork.

Testing purpose, we have changed request URL & added User Id as parameter to v1 branch.

Before merge, need to test v1 collection to make sure that the changes are working as expected. Once, we are ready then merge the changes to parent collection by following steps.

Go to forked collection and click the ellipsis (…) and click Merge changes.

If multiple forked collections are being worked on simultaneously and a teammate updates the parent collection, then forked collection and the parent collection will be out of sync. In that case if when will go to Merge, it will throw a message: “The original collection has been modified since you last updated the fork. We’d recommend pulling changes before continuing”. Hence, it is always better need to start with a Pull request while going to Merge.

In my case, I changed original master collection & added a parameter 2: So requested URL is looking like:
{{host}}/users/2 to make sure we have conflict.

Go to forked collection and click the ellipsis (…) and click Create Pull Request.

It will redirect us to a web browser & if we check the changes then we can see that it is asking us to resolve the conflict first.

Go to Resolve Conflicts

Select the changes we would like to keep & click on Pull Changes

Provide a pull request change Title as: pull-request-1 & add the Reviewers if we want the change-set to approve before Merge.

Now we can go Merge the changes to Parent branch.

If we would like to decline pull request — > Go to create Pull Request — > Click On Destination — > Go to pull-request-1 — > Click on ellipsis (…) which is very right side of Approve button — > Click on Decline which is left bottom corner of the page — > Click on Decline Request

Postman provides us 3 options to choose from when merging with destination.

  • Merge changes – The destination (in this case, the parent collection) will be updated with the changes from the source (in this case, the forked collection) and the forked collection will remain as it is.
  • Merge changes and update source – Both the source and destination will be updated (they’ll be identical).
  • Merge changes and delete source – The destination (in this case parent collection) will be updated and the source (the forked collection) will be deleted.

In my case I selected very last option & clicked on Merge

In Postman I can see the v1 branch got merged to parent & finally deleted.

We can specify Environment variables to current workspace. In our case we added an Environment named as: Local & a variable name as: {{host}} within it. This can be shared to multiple work-spaces & also we can manage the team role as Editor/Viewer.

Hope this article is helpful.

Happy coding!
Tarun Kumar Chatterjee

Author Info

Tarun Kumar Chatterjee
 
Net – Technology Specialist
 
Rate this article
 
Tarun has been working in IT Industry for over 12+ years. He holds a B-tech degree. He is passionate about learning and sharing the tricks and tips in Azure, .Net ...read more
 

Leave a comment