5

I’m trying to programmatically delete shared steps (I am experimenting with export/import, and am generating a large amount, and want to be able to delete them – not manually, one at a time).

Shared steps, like all “hidden” category work item types, cannot be deleted with the delete work item API. Test cases, test plans, and test suites have special APIs to allow their deletion, but I cannot find a similar API for the shared steps.

Does any one know what the API is, or whether there is one, or whether there will be?

2 Answers 2

4

Yes, a shared step is actually a work item type under the covers.

Unlike test plan/suite, there is no related Rest API could directly delete them. Expect deleting manually through web portal. It can only be destroyed by using witadmin destroywi command which is the only available option right now.

Also works with VSTS, you just have to install any edition of VS , the command located at (%programfiles(x86)%\Microsoft Visual Studio 1x.0\Common7\IDE)

To run the witadmin command-line tool, open a Command Prompt window where Visual Studio is installed. The witadmin command-line tool installs with any version of Visual Studio.

You can access this tool by installing the free version of Visual Studio Community.

You'll need to know the ID of the Shared Steps Work Item you want to get rid of.

witadmin destroywi /collection:https://xxx.visualstudio.com /id:123 
Sign up to request clarification or add additional context in comments.

1 Comment

This helped! I actually tried this yesterday, but it didn't work for me. I realize that I missed the credential prompt window that came up. If anyone finds themselves in the same predicament, not that you will get a prompt for your credentials!
0

Able to do via REST API now:

 $token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalToken)")) $header = @{authorization = "Basic $token"} $sharedStepIdFileContent = Get-Content -Path .\SharedStepsIdList.txt $sharedStepIdList = $sharedStepIdFileContent.Split([System.Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries) $sharedStepIdList | % { $sharedStepId = $_ $url = "https://dev.azure.com/{org}/{project}/_apis/test/sharedstep/$($sharedStepId)?api-version=5.0-preview.1" Write-Host "Deleting Shared Step $sharedStepId ..." Invoke-RestMethod -Uri $url -Method Delete -ContentType application/json -Headers $header } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.