Restore Deleted WorkItems in Azure DevOps

Suppose in your project there’s a critical sprint going on and someone by mistake deletes the work item from ADO Boards and spends 10 hours to find a way to restore it back to its glory.

Well you don’t have to waste your time because to restore deleted work items from azure boards you can use Azure REST API’s, I know it is in the jungle of Microsoft Documentation, a different world altogether. Therefore you’ll find everything in this tutorial to restore your deleted work items.

Azure REST APIs can be lifesaver, some say its better than Microsoft application portals.

Prerequisites

  • Access to ADO with permissions to project to confirm restoration.
  • PAT Token from ADO.
  • API Testing tool such as Postman or you can always use CURL.

Steps to Create PAT Token.

  1. Sign in to your organization in Azure DevOps (https://dev.azure.com/{yourorganization}).
  2. From your home page, open your user settings, and then select Personal access tokens.

3. And then select + New Token.

4. Name your token, select the organization where you want to use the token, and then choose a lifespan for your token.

5. Select the scopes for this token to authorize for your specific tasks.

You can select Full Access but in this specific case you can select Work Items with Read, Write and Manage and then select Create. As shown below in picture.

6. When you’re done, make sure to copy the token. For your security, it won’t be shown again. Now you will use this token as your password.

Making Requests in Postman to restore Work Items:

  • In postman’s authentication tab select Basic Auth and provide your ADO username and in place of password paste your PAT token.
  • Now we query to ADO using Microsoft’s RecycleBin APIs. Using the API mentioned below we can get the deleted Work Item.
GET https://dev.azure.com/{organization}/{project}/_apis/wit/recyclebin/{id}?api-version=4.1
  • You should see the JSON representation of deleted Work Item when you hit send in postman with Basic Auth setup and deleted Work Item passed in URL. Please don’t forget to enter project name in URL.
  • Now in the same tab or new, you need to change GET request to PATCH and pass Boolean flag in request’s body. In Postman, you have to send request body in form of JSON to MS APIs as that is only valid content type. Therefore, in the current scenario we just send boolean key isDeleted with value as false
Same as GET URL, just change HTTP method to PATCH
{
"isDeleted":false
}
  • This request should restore your deleted workItem, please search the in your ADO to confirm. After successful restoration of the WorkItems, please revoke the PAT token.

--

--

--

Python & Azure DevOps Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Rusty Shorts — Ownership rules

GitHub and Hugo, a Great Combination for Business Static Website

How to be an Expert in Android Development

How To Mint NFT Programmatically

Apache Hive in the vein!

AWS Elastic Beanstalk | What Is It? | What Are The Benefits?

Why Our World Is Powered By Holochain

How to create test cases, working with Testrail

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anshuman Singh

Anshuman Singh

Python & Azure DevOps Engineer

More from Medium

Azure API Management Policy for operation filter at API level policy

How to access custom attributes from Azure AD-B2C using Graph API(s)

How to add a free SSL certificate to Azure App Service (Auto Renewable)

Enhance security in Dynamics 365 CRM using AAD Security Groups