Queries - Get Queries Batch

Gets a list of queries by ids (Maximum 1000)

POST https://dev.azure.com/{organization}/{project}/_apis/wit/queriesbatch?api-version=7.1

URI Parameters

Name In Required Type Description
organization
path True

string

The name of the Azure DevOps organization.

project
path True

string

Project ID or project name

api-version
query True

string

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

Request Body

Name Type Description
$expand

QueryExpand

The expand parameters for queries. Possible options are { None, Wiql, Clauses, All, Minimal }

errorPolicy

QueryErrorPolicy

The flag to control error policy in a query batch request. Possible options are { Fail, Omit }.

ids

string[]

The requested query ids

Responses

Name Type Description
200 OK

QueryHierarchyItem[]

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

Gets a list of queries by ids

Sample request

POST https://dev.azure.com/fabrikam/{project}/_apis/wit/queriesbatch?api-version=7.1

{
  "ids": [
    "c6725763-d9ae-487e-bb42-00222e2f4d9f",
    "c19eec2d-07a0-4c20-be57-3f7903792ca6",
    "298f94fd-30ea-40f3-8d25-3202c9effa3a"
  ]
}

Sample response

{
  "count": 3,
  "value": [
    {
      "id": "c6725763-d9ae-487e-bb42-00222e2f4d9f",
      "name": "Work Items With Summary Values",
      "path": "Shared Queries/Troubleshooting/Work Items With Summary Values",
      "createdBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "createdDate": "2018-09-26T19:01:44.6Z",
      "lastModifiedBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "lastModifiedDate": "2018-09-26T19:01:44.6Z",
      "queryType": "oneHop",
      "isPublic": true,
      "_links": {
        "self": {
          "href": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/queries/c6725763-d9ae-487e-bb42-00222e2f4d9f"
        },
        "html": {
          "href": "http://localhost:8080/tfs/web/qr.aspx?pguid=833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d&qid=c6725763-d9ae-487e-bb42-00222e2f4d9f"
        },
        "parent": {
          "href": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/queries/0389af80-0be8-4c1b-800e-9e91d081e052"
        },
        "wiql": {
          "href": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/wiql/c6725763-d9ae-487e-bb42-00222e2f4d9f"
        }
      },
      "url": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/queries/c6725763-d9ae-487e-bb42-00222e2f4d9f"
    },
    {
      "id": "c19eec2d-07a0-4c20-be57-3f7903792ca6",
      "name": "Product Planning",
      "path": "Shared Queries/Product Planning",
      "createdBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "createdDate": "2018-09-26T19:01:44.6Z",
      "lastModifiedBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "lastModifiedDate": "2018-09-26T19:01:44.6Z",
      "queryType": "flat",
      "isPublic": true,
      "_links": {
        "self": {
          "href": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/queries/c19eec2d-07a0-4c20-be57-3f7903792ca6"
        },
        "html": {
          "href": "http://localhost:8080/tfs/web/qr.aspx?pguid=833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d&qid=c19eec2d-07a0-4c20-be57-3f7903792ca6"
        },
        "parent": {
          "href": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/queries/06285cdf-e6f2-4230-80fd-66a2e11116d2"
        },
        "wiql": {
          "href": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/wiql/c19eec2d-07a0-4c20-be57-3f7903792ca6"
        }
      },
      "url": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/queries/c19eec2d-07a0-4c20-be57-3f7903792ca6"
    },
    {
      "id": "298f94fd-30ea-40f3-8d25-3202c9effa3a",
      "name": "Current Iteration",
      "path": "Shared Queries/Current Iteration",
      "createdBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "createdDate": "2018-09-26T19:01:44.6Z",
      "lastModifiedBy": {
        "displayName": "Jamal Hartnett",
        "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "_links": {
          "avatar": {
            "href": "https://dev.azure.com/mseng/_apis/GraphProfile/MemberAvatars/aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
          }
        },
        "id": "d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "uniqueName": "fabrikamfiber4@hotmail.com",
        "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=d291b0c4-a05c-4ea6-8df1-4b41d5f39eff",
        "descriptor": "aad.YTkzODFkODYtNTYxYS03ZDdiLWJjM2QtZDUzMjllMjM5OTAz"
      },
      "lastModifiedDate": "2018-09-26T19:01:44.6Z",
      "isFolder": true,
      "hasChildren": true,
      "isPublic": true,
      "_links": {
        "self": {
          "href": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/queries/298f94fd-30ea-40f3-8d25-3202c9effa3a"
        },
        "html": {
          "href": "http://localhost:8080/tfs/web/qr.aspx?pguid=833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d&qid=298f94fd-30ea-40f3-8d25-3202c9effa3a"
        },
        "parent": {
          "href": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/queries/06285cdf-e6f2-4230-80fd-66a2e11116d2"
        }
      },
      "url": "https://dev.azure.com/fabrikam/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/833d31e3-4fc9-48f4-9eef-4a0e9d8cf21d/_apis/wit/queries/298f94fd-30ea-40f3-8d25-3202c9effa3a"
    }
  ]
}

Definitions

Name Description
IdentityReference

Describes a reference to an identity.

LinkQueryMode

The link query mode.

LogicalOperation

Logical operator separating the condition clause

QueryBatchGetRequest

Describes a request to get a list of queries

QueryErrorPolicy

The flag to control error policy in a query batch request. Possible options are { Fail, Omit }.

QueryExpand

The expand parameters for queries. Possible options are { None, Wiql, Clauses, All, Minimal }

QueryHierarchyItem

Represents an item in the work item query hierarchy. This can be either a query or a folder.

QueryRecursionOption

The recursion option for use in a tree query.

QueryType

The type of query.

ReferenceLinks

The class to represent a collection of REST reference links.

WorkItemFieldOperation

Describes a work item field operation.

WorkItemFieldReference

Reference to a field in a work item

WorkItemQueryClause

Represents a clause in a work item query. This shows the structure of a work item query.

WorkItemQuerySortColumn

A sort column.

IdentityReference

Describes a reference to an identity.

Name Type Description
_links

ReferenceLinks

This field contains zero or more interesting links about the graph subject. These links may be invoked to obtain additional relationships or more detailed information about this graph subject.

descriptor

string

The descriptor is the primary way to reference the graph subject while the system is running. This field will uniquely identify the same graph subject across both Accounts and Organizations.

directoryAlias

string

Deprecated - Can be retrieved by querying the Graph user referenced in the "self" entry of the IdentityRef "_links" dictionary

displayName

string

This is the non-unique display name of the graph subject. To change this field, you must alter its value in the source provider.

id

string

imageUrl

string

Deprecated - Available in the "avatar" entry of the IdentityRef "_links" dictionary

inactive

boolean

Deprecated - Can be retrieved by querying the Graph membership state referenced in the "membershipState" entry of the GraphUser "_links" dictionary

isAadIdentity

boolean

Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsAadUserType/Descriptor.IsAadGroupType)

isContainer

boolean

Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsGroupType)

isDeletedInOrigin

boolean

name

string

Legacy back-compat property. This has been the WIT specific value from Constants. Will be hidden (but exists) on the client unless they are targeting the newest version

profileUrl

string

Deprecated - not in use in most preexisting implementations of ToIdentityRef

uniqueName

string

Deprecated - use Domain+PrincipalName instead

url

string

This url is the full route to the source resource of this graph subject.

LinkQueryMode

The link query mode.

Name Type Description
linksOneHopDoesNotContain

string

Returns work items that satisfy the source, only if no linked work item satisfies the link and target criteria.

linksOneHopMayContain

string

Returns work items that satisfy the source and link criteria, even if no linked work item satisfies the target criteria.

linksOneHopMustContain

string

Returns work items where the source, target, and link criteria are all satisfied.

linksRecursiveDoesNotContain

string

linksRecursiveMayContain

string

Returns work items a hierarchy of work items that by default satisfy the source

linksRecursiveMustContain

string

workItems

string

Returns flat list of work items.

LogicalOperation

Logical operator separating the condition clause

Name Type Description
and

string

none

string

or

string

QueryBatchGetRequest

Describes a request to get a list of queries

Name Type Description
$expand

QueryExpand

The expand parameters for queries. Possible options are { None, Wiql, Clauses, All, Minimal }

errorPolicy

QueryErrorPolicy

The flag to control error policy in a query batch request. Possible options are { Fail, Omit }.

ids

string[]

The requested query ids

QueryErrorPolicy

The flag to control error policy in a query batch request. Possible options are { Fail, Omit }.

Name Type Description
fail

string

omit

string

QueryExpand

The expand parameters for queries. Possible options are { None, Wiql, Clauses, All, Minimal }

Name Type Description
all

string

Expands all properties

clauses

string

Expands Columns, Links, ChangeInfo, WIQL text and clauses

minimal

string

Displays minimal properties and the WIQL text

none

string

Expands Columns, Links and ChangeInfo

wiql

string

Expands Columns, Links, ChangeInfo and WIQL text

QueryHierarchyItem

Represents an item in the work item query hierarchy. This can be either a query or a folder.

Name Type Description
_links

ReferenceLinks

Link references to related REST resources.

children

QueryHierarchyItem[]

The child query items inside a query folder.

clauses

WorkItemQueryClause

The clauses for a flat query.

columns

WorkItemFieldReference[]

The columns of the query.

createdBy

IdentityReference

The identity who created the query item.

createdDate

string

When the query item was created.

filterOptions

LinkQueryMode

The link query mode.

hasChildren

boolean

If this is a query folder, indicates if it contains any children.

id

string

The id of the query item.

isDeleted

boolean

Indicates if this query item is deleted. Setting this to false on a deleted query item will undelete it. Undeleting a query or folder will not bring back the permission changes that were previously applied to it.

isFolder

boolean

Indicates if this is a query folder or a query.

isInvalidSyntax

boolean

Indicates if the WIQL of this query is invalid. This could be due to invalid syntax or a no longer valid area/iteration path.

isPublic

boolean

Indicates if this query item is public or private.

lastExecutedBy

IdentityReference

The identity who last ran the query.

lastExecutedDate

string

When the query was last run.

lastModifiedBy

IdentityReference

The identity who last modified the query item.

lastModifiedDate

string

When the query item was last modified.

linkClauses

WorkItemQueryClause

The link query clause.

name

string

The name of the query item.

path

string

The path of the query item.

queryRecursionOption

QueryRecursionOption

The recursion option for use in a tree query.

queryType

QueryType

The type of query.

sortColumns

WorkItemQuerySortColumn[]

The sort columns of the query.

sourceClauses

WorkItemQueryClause

The source clauses in a tree or one-hop link query.

targetClauses

WorkItemQueryClause

The target clauses in a tree or one-hop link query.

url

string

wiql

string

The WIQL text of the query

QueryRecursionOption

The recursion option for use in a tree query.

Name Type Description
childFirst

string

Returns work items that satisfy the target criteria, even if no work item satisfies the source and link criteria.

parentFirst

string

Returns work items that satisfy the source, even if no linked work item satisfies the target and link criteria.

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.

The class to represent a collection of REST reference links.

Name Type Description
links

object

The readonly view of the links. Because Reference links are readonly, we only want to expose them as read only.

WorkItemFieldOperation

Describes a work item field operation.

Name Type Description
name

string

Friendly name of the operation.

referenceName

string

Reference name of the operation.

WorkItemFieldReference

Reference to a field in a work item

Name Type Description
name

string

The friendly name of the field.

referenceName

string

The reference name of the field.

url

string

The REST URL of the resource.

WorkItemQueryClause

Represents a clause in a work item query. This shows the structure of a work item query.

Name Type Description
clauses

WorkItemQueryClause[]

Child clauses if the current clause is a logical operator

field

WorkItemFieldReference

Field associated with condition

fieldValue

WorkItemFieldReference

Right side of the condition when a field to field comparison

isFieldValue

boolean

Determines if this is a field to field comparison

logicalOperator

LogicalOperation

Logical operator separating the condition clause

operator

WorkItemFieldOperation

The field operator

value

string

Right side of the condition when a field to value comparison

WorkItemQuerySortColumn

A sort column.

Name Type Description
descending

boolean

The direction to sort by.

field

WorkItemFieldReference

A work item field.