0

The answer here works for a single project, Azure DevOps Rest API - Unable To Create New Iteration

But fails when you loop through multiple projects as it seems the way the the API works in the link above it creates an iteration which has a name which is unique across all projects, rather than an iteration name that can be used across multiple projects.

I've come to the conclusion that this isn't possible reading through all the docs / info I can find online. So checking to see if anyone here has found a solution to this. And for this requirement, the iteration names need to be identical across all projects due to reasons I won't bore you with here. This feature is available via the user interface when adding an iteration, so seems odd that it doesn't work via the APIs.

Error Message:

{
    "$id": "1",
    "innerException": null,
    "message": "VS402371: Classification node name Sprint 2020-06-24 is already in use by a different child of parent classification node {GUID removed}. Choose a different name and try again.",
    "typeName": "Microsoft.TeamFoundation.WorkItemTracking.Server.Metadata.ClassificationNodeDuplicateNameException, Microsoft.TeamFoundation.WorkItemTracking.Server",
    "typeKey": "ClassificationNodeDuplicateNameException",
    "errorCode": 0,
    "eventId": 3200
}
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
Michael Cropper
  • 872
  • 1
  • 10
  • 28
  • What do you mean "But fails when you loop through multiple projects"? what did you try? – Shayki Abramczyk Jun 24 '20 at 15:02
  • The code on the link above, but replaced the URL to be the different projects within the same organisation. Comes back with a 411 error and fails to create the project. Added the error message to the original question for completeness. – Michael Cropper Jun 24 '20 at 15:07

1 Answers1

0

Based on my test, if you replace the Project name in the URL, the Rest API still could run successfully.

Here are my test steps and results:

For Project 1: URL: Post

https://dev.azure.com/{Org name}/Project1/_apis/wit/classificationnodes/Iterations?api-version=5.0

Result: Success

enter image description here

For Project2

URL: Post

https://dev.azure.com/{Org name}/Project2/_apis/wit/classificationnodes/Iterations?api-version=5.0

Result: success

enter image description here

I only change the Project name . The request bodys are same. In the result, the Iteration path are different. So they will not have conflicts.

From the error message, it seems that the Iteration name already exists in the target project.

You could check the Iteration name in the Project Settings -> Project configuration -> Iterations.

Or you could use this Rest API to get Classification Nodes and child iterations.Then you can search the node (already contain the Iteration name) through the classification node (GUID in error message)in the API Result.

Get  https://dev.azure.com/{Orgname}/Project2/_apis/wit/classificationnodes?$depth=2&api-version=5.0

Please make sure that this Iteration name is unique in the node.

Updates:

Of course. We could archive this via Rest API.

You could use this rest api to add the Iteration to the Sprints list.

URL:

Post https://dev.azure.com/orgname/Projectname/{team}/_apis/work/teamsettings/iterations?api-version=5.1

Request Body:

{
    "id":" Iteration identifier id"
}

Then the Ieration could be added to the Sprints list.

Result

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • Ignore me...School boy error.... Missed posting the JsonBody in the actual request in the code. Joys of rushing... What I have noticed though is that while this creates the Project Iteration, it doesn't actually create the Sprint in the list of Sprints on the Backlog page on the right. Does that part still need to happen manually or is there a way to do that via another API? – Michael Cropper Jun 25 '20 at 08:57
  • @MichaelCropper. Please check the update. We could achive this via API. Hope this helps. – Kevin Lu-MSFT Jun 25 '20 at 09:19
  • Thanks Kevin - To confirm, is that the Team Name or the Team ID? – Michael Cropper Jun 25 '20 at 09:22
  • 1
    Team name is enough. – Kevin Lu-MSFT Jun 25 '20 at 09:24