Using the Azure DevOps REST API, I am trying to get a list of all the workItems associated with each Iteration, but am mostly getting an empty return.
I start with the following call to get the list of all Iterations :
https://dev.azure.com/{organisation}/{project}/_apis/wit/classificationnodes?$depth=3
This successfully gives me a large list of all Iterations - the 2 most recent ones shown
{
"id": 459,
"identifier": "b72c09b4-4e9f-4b4b-a3bc-0daff628bf4d",
"name": "Release 206",
"structureType": "iteration",
"hasChildren": false,
"attributes": {
"startDate": "2024-11-08T00:00:00Z",
"finishDate": "2024-12-05T00:00:00Z"
},
"path": "\\Digital-Web-and-Apps\\Iteration\\Release 206",
"url": "https://dev.azure.com/BG/c6c8a298-a2e5-43de-9bc0-0d0a15f2eadc/_apis/wit/classificationNodes/Iterations/Release%20206"
},
{
"id": 485,
"identifier": "9ecb6083-4d82-4584-93aa-97bf7877bb2f",
"name": "Release 208",
"structureType": "iteration",
"hasChildren": false,
"attributes": {
"startDate": "2025-01-02T00:00:00Z",
"finishDate": "2025-01-23T00:00:00Z"
},
"path": "\\Digital-Web-and-Apps\\Iteration\\Release 208",
"url": "https://dev.azure.com/BG/c6c8a298-a2e5-43de-9bc0-0d0a15f2eadc/_apis/wit/classificationNodes/Iterations/Release%20208"
}
I then use the identifier in this call to get all the workItems in the current Iteration
https://dev.azure.com/{organisation}/{project}/_apis/work/teamsettings/iterations/9ecb6083-4d82-4584-93aa-97bf7877bb2f/workitems?api-version=7.1 - the first 2 workItems shown
{
"workItemRelations": [
{
"rel": null,
"source": null,
"target": {
"id": 26963,
"url": "https://dev.azure.com/BG/_apis/wit/workItems/26963"
}
},
{
"rel": null,
"source": null,
"target": {
"id": 26944,
"url": "https://dev.azure.com/BG/_apis/wit/workItems/26944"
}
},
But the same call for any earlier Iteration e.g.
returns with workItemRelations empty
{
"workItemRelations": [],
"url": "https://dev.azure.com/BerkeleyGroupDevOps/c6c8a298-a2e5-43de-9bc0-0d0a15f2eadc/9829b5e6-8fd2-43df-b674-1e1a8a500e3e/_apis/work/teamsettings/iterations/b72c09b4-4e9f-4b4b-a3bc-0daff628bf4d/workitems",
I would have expected to get the list of workItems (there definitely are some) but nothing gets returned.
Can anyone explain why only the current Iteration returns workItems please?
I tested the same API that you are using in my side, and it works.
The result it returns matches with the work items in the Sprint page for each iteration.
For example:
Please check if you can see the work items in the Sprint page for the earlier iteration.
Update:
I can reproduce the issue when I chose an old Iteration in another organization with the API you shared.
I checked the Iterations - Get Iteration Work Items API again and found that the API needs the Team ID or team name in the URI Parameters.
GET https://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/iterations/{iterationId}/workitems?api-version=7.2-preview.1
After adding the team name in the URL, it works!
The following is the comparison screenshot: