Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete an annotated tag (git tag) in VSTS API?

I'm able to successfully create an annotated tag (git tag) with the request below, but I'm not able to programmatically delete it.

POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/annotatedtags?api-version=4.1-preview.1

Request:

{
    "name": "wagner-test-3",
    "message": "wagner-test-3",
    "taggedObject": {
        "objectId": "aaaaab6cad84a07b7bd65cf3519142a12f856baa"
    }
}

According to the documentation there is no delete endpoint, so I've tried the delete ref endpoint but no luck so far. It only returns 400 (Invalid Request).

DELETE https://dev.azure.com/{organization}/{project}/_apis/git/favorites/refs/{favoriteId}?api-version=4.1-preview.1

Response:

{
    "count": 1,
    "value": {
        "Message": "The request is invalid."
    }
}

Thanks.

like image 722
Wagner DosAnjos Avatar asked Oct 21 '25 07:10

Wagner DosAnjos


1 Answers

I was able to figure out my own question. The way to delete an annotated tag is to update it with the Refs API. This is not well documented though.

POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/refs?api-version=4.1

Request:

[
    {
        "name": "refs/tags/wagner-test-3",
        "newObjectId": "0000000000000000000000000000000000000000",
        "oldObjectId": "aaaaab6cad84a07b7bd65cf3519142a12f856baa"
    }
]

Azure DevOps documentation: Refs - Update Refs Creating, updating, or deleting refs(branches).

like image 58
Wagner DosAnjos Avatar answered Oct 23 '25 12:10

Wagner DosAnjos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!