How to get the current Azure Devops iteration name for a project using Power Automate

I was doing some investigation on how I could automate some standard messages we send for my team related to some sprint tasks using Power Automate, and one simple requirement was to automatically detect the current sprint (iteration) name, to make an email content dynamic.

The problem
There is one action in Power Automate to get iterations, but it does not have a filtering option.

We could leverage this one in combination with the Filter array action in Power Automate, but I was wondering if I could make it in a more performant way and with only one action.


The solution

Azure DevOps also has a Rest API that we can leverage to do actions that are not available out of the box.
We can run a query to get the current iterations using a GET request on the the Iterations endpoint, as below:

https://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/iterations

And it has a parameter that allows us to receive only the current iteration:

https://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/iterations?$timeframe=current


Power Automate also has a Send an HTTP request action for Azure DevOps, so we can use this action to call this endpoint and get the current iteration for a project.


The Flow pieces
First step, run the Send an HTTP Request to Azure DevOps action obtain the current project iteration data using the iterations endpoint and filtering by the current iteration:

You will then get as a response a JSON object following the structure below:

{
  "count": 1,
  "value": [
    {
      "id": "<Guid>",
      "name": "<Iteration name>",
      "path": "<Path>",
      "attributes": {
        "startDate": "<DateTime String>",
        "finishDate": "<DateTime String>",
        "timeFrame": "current"
      },
      "url": "<Iteration API enpoint>"
    }
  ]
}

As the information returned comes in an array format on the value property (even though with only one item), you can use the following expression to access it (rename the Send_an_HTTP_request_to_Azure_DevOps piece if you rename your action):

first(body('Send_an_HTTP_request_to_Azure_DevOps')?['value'])?['name']

If you add this expression in a compose action and run a manually triggered flow as below, you will get the correct project iteration name in the Compose box:

Conclusion
Similar to what we do with SharePoint and Graph, we can use a Rest API from Azure DevOps to run some actions that are not available as standard Power Automate actions.

Reference

Iterations – List – Microsoft Learn

Filter array – Power Automate – Microsoft Learn

Azure DevOps – Connectors – Microsoft Learn

Leave a Reply

Your email address will not be published. Required fields are marked *