Why is Azure Devops IterationId an Int for Workitem History?

Viewed 377

I'm using the Azure DevOps API to query work items to understand the history of how the iteration has changed over time.

So I start with a typical work item query like so:

https://[ourserver]/[collection]/[project]/_apis/wit/workItems/[wi-id]/updates

And in the returned JSON I can see iteration changes. So far so good.

"System.IterationId": {
   "oldValue": 11068,
   "newValue": 11529
},

My problem is when I try to retrieve the full iteration record associated with those IDs. The REST API seems to use GUIDs for IDs, not ints. Here's an example:

https://[ourserver]/[collection]/[project]/[team]/apis/work/teamsettings/iterations

{
   "id": "3c117833-d770-47f1-a483-65461c440721",
   "name": "Sprint 3",
   "path": "aa\\bb\\cc\\Sprint 3",
   "attributes": {
      "startDate": "2020-02-05T00:00:00Z",
      "finishDate": "2020-02-18T00:00:00Z",
      "timeFrame": "past"
}

So where is the magic link between the System.IterationId in a workitem's history and GUID used for iteration ids in the REST API?

1 Answers

You can get the iterations id with the Classification Nodes - Get Classification Nodes Rest API:

GET https://dev.azure.com/{organization}/{project}/_apis/wit/classificationnodes?ids={ids}&api-version=5.1

You can use the URL parameter $depth=2 to get also the children.

In the results, you will get id that is the System.IterationId value you get in the work item updates, and identifier that it's the GUID you get with the teamsettings/iterations api.

Related