Test variables

Last Update: 12/5/2016

api-version = 3.0-preview

If you haven't already, look at the information on getting started with these APIs.

Get a list of test variables

GET https://{instance}/DefaultCollection/{project}/_apis/test/variables?api-version={version}[&$skip={int}&$top={int}]
Parameter Type Default Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Name or ID of the team project.
Query
api-version string Version of the API to use.
$skip int Number of test variables to skip.
$top int Number of test variables to return.

Sample request

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/variables?api-version=3.0-preview.1

Sample response

Status code: 200
{
  "value": [
    {
      "id": 1,
      "name": "Operating System",
      "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Variables/1",
      "project": {
        "name": "fabrikam-fiber-tfvc",
        "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
      },
      "description": "Default operating systems",
      "revision": 1,
      "values": [
        "Windows 10",
        "Windows 7",
        "Windows 8",
        "Windows 8.1"
      ]
    },
    {
      "id": 2,
      "name": "Browser",
      "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Variables/2",
      "project": {
        "name": "fabrikam-fiber-tfvc",
        "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
      },
      "description": "Default browsers",
      "revision": 1,
      "values": [
        "Chrome",
        "Edge",
        "FireFox",
        "Internet Explorer 11.0",
        "Safari"
      ]
    },
    {
      "id": 3,
      "name": "Renamed Language",
      "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Variables/3",
      "project": {
        "name": "fabrikam-fiber-tfvc",
        "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
      },
      "description": "Language for testing",
      "revision": 2,
      "values": [
        "English - UK",
        "English - US",
        "Japanese"
      ]
    }
  ],
  "count": 3
}

A page at a time

Sample request

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/variables?$top=2&api-version=3.0-preview.1

Sample response

Status code: 200
{
  "value": [
    {
      "id": 2,
      "name": "Browser",
      "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Variables/2",
      "project": {
        "name": "fabrikam-fiber-tfvc",
        "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
      },
      "description": "Default browsers",
      "revision": 1,
      "values": [
        "Chrome",
        "Edge",
        "FireFox",
        "Internet Explorer 11.0",
        "Safari"
      ]
    },
    {
      "id": 3,
      "name": "Renamed Language",
      "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Variables/3",
      "project": {
        "name": "fabrikam-fiber-tfvc",
        "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
      },
      "description": "Language for testing",
      "revision": 2,
      "values": [
        "English - UK",
        "English - US",
        "Japanese"
      ]
    }
  ],
  "count": 2
}

Get a test variable

GET https://{instance}/DefaultCollection/{project}/_apis/test/variables/{variableId}?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Name or ID of the team project.
variableId int ID of the test variable to get.
Query
api-version string Version of the API to use.

Sample request

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/variables/1?api-version=3.0-preview.1

Sample response

Status code: 200
{
  "id": 1,
  "name": "Operating System",
  "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Variables/1",
  "project": {
    "name": "fabrikam-fiber-tfvc",
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
  },
  "description": "Default operating systems",
  "revision": 1,
  "values": [
    "Windows 10",
    "Windows 7",
    "Windows 8",
    "Windows 8.1"
  ]
}

Create a test variable

POST https://{instance}/DefaultCollection/{project}/_apis/test/variables?api-version={version}
Content-Type: application/json
{
  "name": {string},
  "description": {string},
  "values": {Array of string}
}
Parameter Type Default Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Name or ID of the team project.
Query
api-version string Version of the API to use.
Body
name string Name of the new test variable.
description string Description of the new test variable.
values string List of values allowed for the test variable.

Sample request

POST https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/variables?api-version=3.0-preview.1
Content-Type: application/json
{
  "name": "Language",
  "description": "Language for testing",
  "values": [
    "English - US",
    "English - UK"
  ]
}

Sample response

Status code: 200
{
  "id": 3,
  "name": "Language",
  "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Variables/3",
  "project": {
    "name": "fabrikam-fiber-tfvc",
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
  },
  "description": "Language for testing",
  "revision": 1,
  "values": [
    "English - UK",
    "English - US"
  ]
}

Update a test variable

PATCH https://{instance}/DefaultCollection/{project}/_apis/test/variables/{variableId}?api-version={version}
Content-Type: application/json
{
  "name": {string},
  "description": {string},
  "values": {Array of string}
}
Parameter Type Default Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Name or ID of the team project.
variableId int ID of the test variable to update.
Query
api-version string Version of the API to use.
Body
name string Name of the test variable.
description string Description of the test variable.
values string List of values allowed for the test variable.

Sample request

PATCH https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/variables/3?api-version=3.0-preview.1
Content-Type: application/json
{
  "values": [
    "English - US",
    "English - UK",
    "Japanese"
  ]
}

Sample response

Status code: 200
{
  "id": 3,
  "name": "Renamed Language",
  "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Variables/3",
  "project": {
    "name": "fabrikam-fiber-tfvc",
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
  },
  "description": "Language for testing",
  "revision": 2,
  "values": [
    "English - UK",
    "English - US",
    "Japanese"
  ]
}

Delete a test variable

DELETE https://{instance}/DefaultCollection/{project}/_apis/test/variables/{variableId}?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Name or ID of the team project.
variableId int ID of the test variable to delete.
Query
api-version string Version of the API to use.

Sample request

DELETE https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/variables/1?api-version=3.0-preview.1

Sample response

Status code: 204