0

I use a powershell script to call the azure rest api and add new iterations and delete the three basic iteration.

For the api it work, if i get the list of iterations Iteration 1 to 3 are deleted, however if i go to the GUI there are still here :enter image description here

Did i miss something ?

Code

function deleteIteration {
    [CmdletBinding()] param ( 
        [Parameter( Mandatory )] [string]    $organization,
        [Parameter( Mandatory )] [string]    $project,
        [Parameter( Mandatory )] [string]    $iteration,
        [Parameter( Mandatory )] [hashtable] $header
    )

    try {

        [string] $team        = getMainTeamName -organization $organization -project $project
        [string] $iterationId = getIterationId -organization $organization -project $project -iteration $iteration -team $team -header $header
        [string] $uri         = "$url/{0}/{1}/{2}/_apis/work/teamsettings/iterations/{3}?{4}" -f $organization, $project, $team, $iterationId, $apiVersion
        [Object] $query       = Invoke-RestMethod -Uri $uri -Method Delete -Headers $header

        Write-Host "- Iteration $iteration has been deleted !"

    } catch {
        Write-Host "##[error] An error occurred while deleting Iteration $name at $uri."
        Get-Error
        throw
    }
}
4
  • Can you share the current PowerShell script sample with us? This will be helpful to figure out the issue in the script. Commented May 17, 2024 at 9:21
  • I'll do that in the main post. Commented May 17, 2024 at 9:26
  • Thanks for your update. I will check the issue. Commented May 17, 2024 at 9:33
  • Based on your screenshot and powershell script, you need to delete the iteration at the project level. You need to change to use this Rest api: learn.microsoft.com/en-us/rest/api/azure/devops/wit/… For more detailed info, you can refer to my answer. Commented May 17, 2024 at 10:03

1 Answer 1

2

From your screenshot, you need to delete the iteration in the Project Settings -> Project Configuration -> Itertaions (Project Level).

For example:

enter image description here

When you use the Rest API:Iterations - Delete, it will delete the iteration at Team level(Project Settings -> Team Configuration -> Itertaions).

For example:

enter image description here

It will not delete the iteration at the Project Level.

To solve this issue, you need change to use the Rest API: Classification Nodes - Delete

DELETE https://dev.azure.com/{organization}/{project}/_apis/wit/classificationnodes/{structureGroup}/{path}?api-version=5.1

structureGroup: iterations

path: Iteration name(e.g. Iteration 1, Iteration 2,Iteration 3)

For example:

https://dev.azure.com/{organization}/{project}/_apis/wit/classificationnodes/iterations/Iteration 1?api-version=5.1

Then it will delete the iteration at project level.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.