VS402881:未指定与工件源相对应的工件版本 'MyBuild.' 发布管理 vNext REST API

VS402881: No artifact version is specified corresponding to artifact source 'MyBuild.' Release Management vNext REST API

我正在使用 TFS 2015.2 RTM,我刚刚发现发布管理 vNext REST API 在 2.2-preview.1 内部部署中。我想创建一个版本,但我不知道要放入 POST 请求正文中的确切 JSON,因为 documentation 仅适用于 VSTS。

当我发送请求时,收到错误消息:

VS402881: No artifact version is specified corresponding to artifact source 'MyBuild.' Specify a valid value and try again. 

这是 JSON:

$body = @"
     {
          definitionId": 1,
    "description": "test",
    "artifacts": [ 
      {
         "alias": "Tailspin Toys", 
         "version": {
               "id": 147,
         },
         "instanceReference": {
            "id": 5
        }
       }
     ]
} 
"@

下面是 Invoke-RestMethod 命令:

$releaseResponse = Invoke-RestMethod -Method Post -Credential $credential -ContentType application/json -Uri $postUri -Body $body

我缺少什么 JSON 项?如果文档没有缺失的内容,我如何找到要放入 JSON 正文的内容?

是的,当前版本的 VSTS APIs 和 TFS 2015.2 APIs 之间存在一些差异。但是大多数 APIs 应该工作,除了极少数。这是 documentation link.

以下是创建版本所需的 JSON。 所需的 JSON 需要在 instanceReference 中包含 name,尽管它对于当前版本的 VSTS API.

是可选的
{
  "definitionId": 1,
  "description": "test",
  "artifacts": [
    {
      "alias": "Tailspin Toys",
      "instanceReference": {
        "id": "5",
        "name": "<build_name>"
      }
    }
  ]
}

基于我的 Fiddler 捕获:

{
  "id": 0,
  "name": "xxx",
  "createdOn": "2016-04-15T06:48:14.173Z",
  "createdBy": null,
  "modifiedBy": null,
  "modifiedOn": null,
  "environments": [
    {
      "id": 0,
      "name": "Default Environment",
      "rank": 1,
      "deployStep": {
        "id": 0,
        "tasks": [ ]
      },
      "owner": {
        "displayName": "foobar",
        "id": "c236ac37-97ee-4ed0-b731-36ebb4a9ed3f",
        "isContainer": false,
        "uniqueName": "ad\foobar",
        "imageUrl": "http://tfs:8080/tfs/collection/_api/_common/IdentityImage?id=c236ac37-97ee-4ed0-b731-36ebb4a9ed3f&t=1460698957392&__v=5",
        "url": "http://tfs:8080/tfs/collection/"
      },
      "queueId": 1,
      "demands": [ ],
      "conditions": [ ],
      "variables": { },
      "runOptions": { "EnvironmentOwnerEmailNotificationType": "Always" },
      "executionPolicy": {
        "concurrencyCount": 0,
        "queueDepthCount": 0
      },
      "preDeployApprovals": {
        "approvals": [
          {
            "rank": 1,
            "isAutomated": true,
            "isNotificationOn": false,
            "id": 0
          }
        ],
        "approvalOptions": null
      },
      "postDeployApprovals": {
        "approvals": [
          {
            "rank": 1,
            "isAutomated": true,
            "isNotificationOn": false,
            "id": 0
          }
        ],
        "approvalOptions": null
      }
    }
  ],
  "artifacts": [ ],
  "variables": { },
  "triggers": [ ],
  "releaseNameFormat": "Release-$(rev:r)",
  "retentionPolicy": { "daysToKeep": 60 }
}

您可以查看示例用法 http://blogs.msdn.com/b/chandananjani/archive/2016/04/15/using-releasemanagement-rest-api-s.aspx

对于类似的错误VS402962:没有指定与工件源对应的工件版本ID 'My build name'。请指定一个有效值并重试。

我按照this article的建议做了...

refresh the page and try again