Site icon Sibeesh Passion

Get Azure DevOps Sprint Capacity Using API and PostMan

Obviously, you can do many things in Azure DevOps, but there may be some cases where you may need to do something special to get what you wanted. Here, I wanted to know my Sprint capacity programmatically as I need to find the average sprint capacity and the area where my team is spending time, whether it is Development or Testing, etc. Unfortunately, there is no option to see that in the Azure DevOps, but luckily there are APIs we can get this information. Here, in this post, we will see how we can get that, let’s get started.

Get the PAT (Personal Access Token)

To connect to our DevOps using an API, we should authenticate and to do that, we need to create a PAT aka Personal Access Token. Goto your Azure DevOps and click on the User Settings button, and then Personal access tokens.

Personal access tokens

Click on the +New Token button and fill all the required fields in the next screen. Once it is done, click on Create button, this will generate a token for you. Please remember that you need to copy this token before you leave the page or reload, as this is not saved anywhere.

Setup PostMan

I usually create a collection in PostMan before I do any related calls. You can create a collection by clicking the + icon in the collection section. Once it is created, click on the Authorization tab and change the type to Basic Auth, past the token you copied from Azure DevOps in the password field. Please remember that you should leave the Username field blank.

Setup PostMan using Azure DevOps Token

Call the Azure DevOps APIs

As we have successfully set up our PostMan, now we are ready to execute the APIs.

Get Iterations

Create a GET request under the collection we have created using this format to get the Iterations as we will use this in our next API call. The example is given below.

GET https://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/iterations?api-version=6.0

The Organization name and project name can be easily found on the Azure DevOps home page or from the URL you access your DevOps, for example, if you access your DevOps by this URL “https://dev.azure.com/sibeeshpassion/publicrepo“, sibeeshpassion is your organization name and publicrepo is your project name.

You can either use your team name or team id as the next parameter. If you want to use the Team id, the easy way to find it is to go to your team by accessing this URL “https://dev.azure.com/{orgName}/{projectName}/_settings/teams“, click on the Team you wish, and then click on either Notification or Dashboard.

Azure DevOps Teams

A new page will be opened and you can get the Team id from the URL of the new page. For example, “https://dev.azure.com/{orgName}/{projectName}/_settings/notifications?teamId=989154f4f-32f6-4dab-b7f5-165457afsgd36f“. One thing to note here is to set the Type as “Inherit auth from parent” under the Authorization tab.

Get API Authorization Type

Click on the Send button now, and you should see the result. You can visualize the data you get by using the visualizer if you wish.

Get the capacity

As we now have all the iteration details we can perform the API call to get the capacity of each sprint. Create another GET request, by using this format and set the Authorization Type as “Inherit auth from parent”. The sample API looks like below,

GET https://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/iterations/{iterationId}/capacities?api-version=6.0

Replace the {iterationId} from the result of the previous execution. When you click on the Send button, you should now get a JSON array with all the details as below.

Please be noted that I have removed all the values from the result. With the result, you can loop through the array and find the analytics data that you are looking for.

Get Capacities API Result

I am planning to create one front end application to do this, thus keep an eye here. You can also get the capacity of the team member by executing this API.

Conclusion

Thanks for reading this post, and here we learned,

  1. How to get a personal access token from Azure DevOps?
  2. How to authnticate the Azure DevOps APIs using the Personal Access Tokens and use the same in PostMan?
  3. How to get the Team Iterations and Sprint Capacities of a Team in Azure DevOps?

About the Author

I am yet another developer who is passionate about writing and video creation. I have written close to 500 blogs on my blog. And I upload videos on my YouTube channels Njan Oru Malayali and Sibeesh Passion. Please feel free to follow me.

Your turn. What do you think?

Thanks a lot for reading. Did I miss anything that you may think is needed in this article? Could you find this post useful? Kindly do not forget to share your feedback.

Kindest Regards

Sibeesh Venu

Exit mobile version