Wiql - Query By Id

Gets the results of the query given the query ID.

GET https://{instance}/{collection}/{project}/{team}/_apis/wit/wiql/{id}?api-version=5.0
GET https://{instance}/{collection}/{project}/{team}/_apis/wit/wiql/{id}?timePrecision={timePrecision}&$top={$top}&api-version=5.0

URI Parameters

Name In Required Type Description
collection
path True

string

The name of the Azure DevOps collection.

id
path True

string

uuid

The query ID.

instance
path True

string

Azure DevOps server name ({server:port})

project
path

string

Project ID or project name

team
path

string

Team ID or team name

api-version
query True

string

Version of the API to use. This should be set to '5.0' to use this version of the api.

$top
query

integer

int32

The max number of results to return.

timePrecision
query

boolean

Whether or not to use time precision.

Responses

Name Type Description
200 OK

WorkItemQueryResult

successful operation

Security

oauth2

Type: oauth2
Flow: accessCode
Authorization URL: https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL: https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer

Scopes

Name Description
vso.work Grants the ability to read work items, queries, boards, area and iterations paths, and other work item tracking related metadata. Also grants the ability to execute queries, search work items and to receive notifications about work item events via service hooks.

Examples

Sample Request

GET https://{instance}/fabrikam/Fabrikam-Fiber-Git/_apis/wit/wiql/{id}?api-version=5.0

Sample Response

{
  "queryType": "tree",
  "asOf": "2014-12-29T20:49:33.803Z",
  "columns": [
    {
      "referenceName": "System.Id",
      "name": "ID",
      "url": "https://fabrikam:8080/tfs/_apis/wit/fields/System.Id"
    },
    {
      "referenceName": "System.WorkItemType",
      "name": "Work Item Type",
      "url": "https://fabrikam:8080/tfs/_apis/wit/fields/System.WorkItemType"
    },
    {
      "referenceName": "System.Title",
      "name": "Title",
      "url": "https://fabrikam:8080/tfs/_apis/wit/fields/System.Title"
    },
    {
      "referenceName": "System.AssignedTo",
      "name": "Assigned To",
      "url": "https://fabrikam:8080/tfs/_apis/wit/fields/System.AssignedTo"
    },
    {
      "referenceName": "System.State",
      "name": "State",
      "url": "https://fabrikam:8080/tfs/_apis/wit/fields/System.State"
    }
  ],
  "workItemRelations": [
    {
      "target": {
        "id": 4,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/4"
      }
    },
    {
      "target": {
        "id": 5,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/5"
      }
    },
    {
      "target": {
        "id": 6,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/6"
      }
    },
    {
      "target": {
        "id": 7,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/7"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 7,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/7"
      },
      "target": {
        "id": 8,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/8"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 7,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/7"
      },
      "target": {
        "id": 9,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/9"
      }
    },
    {
      "target": {
        "id": 11,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/11"
      }
    },
    {
      "target": {
        "id": 12,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/12"
      }
    },
    {
      "target": {
        "id": 20,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/20"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 20,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/20"
      },
      "target": {
        "id": 1,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/1"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 20,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/20"
      },
      "target": {
        "id": 2,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/2"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 20,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/20"
      },
      "target": {
        "id": 3,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/3"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 20,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/20"
      },
      "target": {
        "id": 10,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/10"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 10,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/10"
      },
      "target": {
        "id": 13,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/13"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 10,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/10"
      },
      "target": {
        "id": 14,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/14"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 10,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/10"
      },
      "target": {
        "id": 15,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/15"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 10,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/10"
      },
      "target": {
        "id": 16,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/16"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 10,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/10"
      },
      "target": {
        "id": 17,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/17"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 10,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/10"
      },
      "target": {
        "id": 18,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/18"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 10,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/10"
      },
      "target": {
        "id": 19,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/19"
      }
    },
    {
      "target": {
        "id": 21,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/21"
      }
    },
    {
      "target": {
        "id": 33,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/33"
      }
    },
    {
      "target": {
        "id": 34,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/34"
      }
    },
    {
      "target": {
        "id": 46,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/46"
      }
    },
    {
      "target": {
        "id": 47,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/47"
      }
    },
    {
      "target": {
        "id": 58,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/58"
      }
    },
    {
      "target": {
        "id": 59,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/59"
      }
    },
    {
      "target": {
        "id": 297,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/297"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 297,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/297"
      },
      "target": {
        "id": 299,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/299"
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "source": {
        "id": 297,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/297"
      },
      "target": {
        "id": 300,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/300"
      }
    },
    {
      "target": {
        "id": 298,
        "url": "https://fabrikam:8080/tfs/_apis/wit/workItems/298"
      }
    }
  ]
}

Definitions

Name Description
QueryResultType

The result type

QueryType

The type of query.

WorkItemFieldReference

Reference to a field in a work item

WorkItemLink

A link between two work items.

WorkItemQueryResult

The result of a work item query.

WorkItemQuerySortColumn

A sort column.

WorkItemReference

Contains reference to a work item.

QueryResultType

The result type

Name Type Description
workItem

string

A list of work items (for flat queries).

workItemLink

string

A list of work item links (for OneHop and Tree queries).

QueryType

The type of query.

Name Type Description
flat

string

Gets a flat list of work items.

oneHop

string

Gets a list of work items and their direct links.

tree

string

Gets a tree of work items showing their link hierarchy.

WorkItemFieldReference

Reference to a field in a work item

Name Type Description
name

string

The name of the field.

referenceName

string

The reference name of the field.

url

string

The REST URL of the resource.

A link between two work items.

Name Type Description
rel

string

The type of link.

source

WorkItemReference

The source work item.

target

WorkItemReference

The target work item.

WorkItemQueryResult

The result of a work item query.

Name Type Description
asOf

string

The date the query was run in the context of.

columns

WorkItemFieldReference[]

The columns of the query.

queryResultType

QueryResultType

The result type

queryType

QueryType

The type of the query

sortColumns

WorkItemQuerySortColumn[]

The sort columns of the query.

workItemRelations

WorkItemLink[]

The work item links returned by the query.

workItems

WorkItemReference[]

The work items returned by the query.

WorkItemQuerySortColumn

A sort column.

Name Type Description
descending

boolean

The direction to sort by.

field

WorkItemFieldReference

A work item field.

WorkItemReference

Contains reference to a work item.

Name Type Description
id

integer

Work item ID.

url

string

REST API URL of the resource