Drake S.
Drake S.

Reputation: 1

TFS 2015: Release Definition REST API Issue

I'm trying to make a POST request to create a release. 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}"

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

Upvotes: 0

Views: 411

Answers (2)

Drake S.
Drake S.

Reputation: 1

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.

Upvotes: 0

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31083

The REST API to create a release in TFS 2015 is as below, you could check your 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.

Upvotes: 0

Related Questions