Eric
Eric

Reputation: 3221

Restoring a deleted Work Item on VSTS using REST API

Someone on my team accidentally deleted a VSTS work item. I'm looking at Get Started with REST APIs it looks like I can do this with a small C# program. I'm wondering what I should put in for the personal access token though. Can I get this by doing a fiddler trace while logging into VSTS? Alternatively, is it possible to do this without writing a custom program? I'm using VS 2017 Enterprise.

Upvotes: 0

Views: 708

Answers (3)

starian chen-MSFT
starian chen-MSFT

Reputation: 33698

You can send the REST API request through CURL or Postman tool.

For CURL:

curl -u test:[personal access token] --data {"IsDeleted":false} -X PATCH https://[account].visualstudio.com/DefaultCollection/_apis/wit/recyclebin/[work item id]?api-version=3.0-preview -H "Content-Type:application/json"

For Postman:

enter image description here

enter image description here

Upvotes: 1

Luca Cappa
Luca Cappa

Reputation: 1999

To programmatically play with the Recycle Bin of the Work Items there are these specific REST APIs for Visual Studio Team Services (aka VSTS or VSO).

In particular you can read how to restore a work item

As per Personal Access Token (aka PAT), you should:

  • Create one with proper scope (e.g. Work Item (Read and Write));
  • treat it as a password (e.g. keep it secret and safely stored);
  • use it in place of the password field with HTTPS Basic authentication;

Upvotes: 0

Eric
Eric

Reputation: 3221

The recycle bin icon is (currently) in the lower left hand corner in VSTS, so you can go there to undelete items that you've deleted accidentally. Still be curious for more information on using the REST APIs though.

Upvotes: 0

Related Questions