简体   繁体   English

TFS 2015:版本定义REST API问题

[英]TFS 2015: Release Definition REST API Issue

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

I'm trying to make a POST request to create a release. 我正在尝试发出POST请求以创建发布。 This is the documentation I'm referring to. 这是我要参考的文档 But I get the following error message: 但是我收到以下错误消息:

"VS402881: No artifact version is specified corresponding to artifact source 'example0'. Specify a valid value and try again.\\",\\"typeName\\":\\"Microsoft.VisualStudio.Services.ReleaseManagement.Data.Exceptions.InvalidRequestException, Microsoft.VisualStudio.Services.ReleaseManagement2.Data, Version=14.0.0.0, Culture=neutral, PublicKeyToken=...\\",\\"typeKey\\":\\"InvalidRequestException\\",\\"errorCode\\":0,\\"eventId\\":3000}" “ 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}”

This is an example of my request. 这是我的要求的一个例子。

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

EDIT1: Although the documentation doesn't refer to any "artifact version", I've found the variable through this GET call which returns a "version" under the artifacts. EDIT1:尽管文档中没有提到任何“工件版本”,但我已经通过 GET调用找到了变量, 变量在工件下返回了“版本”。 I've updated my Request Body with the version number as seen below but I still receive the same error. 我已使用以下版本号更新了我的请求正文,但仍然收到相同的错误。

{
  "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"
      }
    }
  ]
}

The REST API to create a release in TFS 2015 is as below, you could check your api: 在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":[]

}

You could also press F12 and create a release in web portal to capture the api to see which part of your api is incorrect. 您也可以按F12键并在Web门户中创建一个发行版以捕获api,以查看api的哪一部分不正确。

Found a solution to my problem. 找到了解决我问题的方法。 It turns out for the Instance Reference, you need to refer to the builds not the build artifacts as one of the documentation suggests. 事实证明,对于实例参考,您需要引用构建而不是文档之一建议的构建工件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM