【问题标题】:How to delete an annotated tag (git tag) in VSTS API?如何在 VSTS API 中删除带注释的标签(git 标签)?
【发布时间】:2018-11-10 19:11:35
【问题描述】:

我能够使用以下请求成功创建一个带注释的标签(git 标签),但我无法以编程方式将其删除。

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

请求:

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

根据documentation,没有删除端点,所以我尝试了delete ref endpoint,但到目前为止没有运气。它只返回 400(无效请求)。

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

回应:

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

谢谢。

【问题讨论】:

    标签: azure-devops azure-devops-rest-api


    【解决方案1】:

    我能够弄清楚我自己的问题。删除带注释的标签的方法是使用 Refs API 更新它。但这并没有很好的记录。

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

    请求:

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

    Azure DevOps 文档: Refs - Update Refs 创建、更新或删除引用(分支)。

    【讨论】:

      猜你喜欢
      • 2016-03-04
      • 2016-11-05
      • 1970-01-01
      • 2011-01-18
      • 2017-08-15
      • 2014-11-16
      • 2020-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多