Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# TFS 2015:发布定义REST API问题 Visual Studio 2017 15.7.5 .Net核心2.1 TFS 2015更新3_C#_Rest_Asp.net Core_Tfs_.net Core - Fatal编程技术网

C# TFS 2015:发布定义REST API问题 Visual Studio 2017 15.7.5 .Net核心2.1 TFS 2015更新3

C# TFS 2015:发布定义REST API问题 Visual Studio 2017 15.7.5 .Net核心2.1 TFS 2015更新3,c#,rest,asp.net-core,tfs,.net-core,C#,Rest,Asp.net Core,Tfs,.net Core,我正试图发出一个POST请求来创建一个发布。这就是我所指的。但我收到以下错误消息: “VS402881:未指定与项目对应的项目版本 源“example0”。请指定有效值并重试 再次说明。\”,\“typeName\:\“Microsoft.VisualStudio.Services.ReleaseManagement.Data.Exceptions.InvalidRequestException, Microsoft.VisualStudio.Services.ReleaseManagement

我正试图发出一个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 portal中创建一个版本来捕获api,以查看您的api的哪一部分不正确。

找到了我的问题的解决方案。事实证明,对于实例引用,您需要引用构建,而不是文档中建议的构建工件