簡體   English   中英

TFS 2015:版本定義REST API問題

[英]TFS 2015: Release Definition REST API Issue

  • Visual Studio 2017 15.7.5
  • .Net Core 2.1
  • TFS 2015更新3

我正在嘗試發出POST請求以創建發布。 這是我要參考的文檔 但是我收到以下錯誤消息:

“ VS402881:未指定與工件源'example0'相對應的工件版本。指定一個有效值,然后重試。\\”,\\“ typeName \\”:\\“ Microsoft.VisualStudio.Services.ReleaseManagement.Data.Exceptions.InvalidRequestException,Microsoft .VisualStudio.Services.ReleaseManagement2.Data,版本= 14.0.0.0,區域性=中性,PublicKeyToken = ... \\“,\\” typeKey \\“:\\” InvalidRequestException \\“,\\” errorCode \\“:0,\\” eventId \\“:3000}”

這是我的要求的一個例子。

{
  "definitionId": 1,
  "description": "Creating Sample release",
  "artifacts": [
    {
      "alias": "example0",
      "instanceReference": [
        {
          "id": "39194",
          "name": "example"
        }
      ]
    },
    {
      "alias": "example0",
      "instanceReference": [
        {
          "id": "39194",
          "name": "example"
        }
      ]
    }
  ]
}

EDIT1:盡管文檔中沒有提到任何“工件版本”,但我已經通過 GET調用找到了變量, 變量在工件下返回了“版本”。 我已使用以下版本號更新了我的請求正文,但仍然收到相同的錯誤。

{
  "definitionId": 1,
  "description": "Creating Sample release",
  "artifacts": [
    {
      "alias": "example0",
      "instanceReference": [
        {
          "id": "123",
          "name": "example0_0"
        }
      ],
      "version": {
        "id": "12345"
      }
    },
    {
      "alias": "exmaple1",
      "instanceReference": [
        {
          "id": "1234",
          "name": "example1_0"
        },
        {
          "id": "42616",
          "name": "example1_1"
        },
        {
          "id": "42617",
          "name": "example1_2"
        }
      ],
      "version": {
        "id": "123456"
      }
    }
  ]
}

在TFS 2015中創建發行版的REST API如下,您可以檢查自己的api:

POST http://TFS2015:8080/tfs/DefaultCollection/{teamproject}/_apis/Release/releases?api-version=2.3-preview.1

{
    "definitionId":1,
    "description":"",
    "artifacts":[
        {
            "alias":"CAT0604",
            "instanceReference":{
                "name":"20180621.2",
                "id":"57",
                "sourceBranch":"$/Scrum-TFVC"

            }

        }
        ],
        "isDraft":false,
        "manualEnvironments":[]

}

您也可以按F12鍵並在Web門戶中創建一個發行版以捕獲api,以查看api的哪一部分不正確。

找到了解決我問題的方法。 事實證明,對於實例參考,您需要引用構建而不是文檔之一建議的構建工件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM