Delen via


Work Items - Get Work Item

Returns a single work item.

GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=7.1
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?fields={fields}&asOf={asOf}&$expand={$expand}&api-version=7.1

URI Parameters

Name In Required Type Description
id
path True

integer

int32

The work item id

organization
path True

string

The name of the Azure DevOps organization.

project
path

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.

$expand
query

WorkItemExpand

The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }.

asOf
query

string

date-time

AsOf UTC date time string

fields
query

string

array (string)

Comma-separated list of requested fields

Responses

Name Type Description
200 OK

WorkItem

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

Get work item
Get work item with asOf parameter

Get work item

Sample request

GET https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/wit/workitems/12?api-version=7.1

Sample response

{
  "id": 12,
  "rev": 3,
  "fields": {
    "System.AreaPath": "MyAgilePrj2",
    "System.TeamProject": "MyAgilePrj2",
    "System.IterationPath": "MyAgilePrj2\\Iteration 1",
    "System.WorkItemType": "User Story",
    "System.State": "Active",
    "System.Reason": "Implementation started",
    "System.AssignedTo": {
      "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"
    },
    "System.CreatedDate": "2017-09-04T06:11:59.05Z",
    "System.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"
    },
    "System.ChangedDate": "2017-10-04T23:32:02.18Z",
    "System.ChangedBy": {
      "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"
    },
    "System.Title": "Epic 2",
    "Microsoft.VSTS.Common.StateChangeDate": "2017-10-04T23:32:01.6Z",
    "Microsoft.VSTS.Common.ActivatedDate": "2017-10-04T23:32:01.6Z",
    "Microsoft.VSTS.Common.ActivatedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
    "Microsoft.VSTS.Common.Priority": 2,
    "Microsoft.VSTS.Common.ValueArea": "Business",
    "System.Tags": "client; sample; teamservices"
  },
  "_links": {
    "self": {
      "href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/12"
    },
    "workItemUpdates": {
      "href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/12/updates"
    },
    "workItemRevisions": {
      "href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/12/revisions"
    },
    "workItemHistory": {
      "href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/12/history"
    },
    "html": {
      "href": "https://dev.azure.com/fabrikam/web/wi.aspx?pcguid=20cda608-32f0-4e6e-9b7c-8def7b38d15a&id=12"
    },
    "workItemType": {
      "href": "https://dev.azure.com/fabrikam/54332e84-3d54-4c67-9bd0-0e88a9849330/_apis/wit/workItemTypes/User%20Story"
    },
    "fields": {
      "href": "https://dev.azure.com/fabrikam/_apis/wit/fields"
    }
  },
  "url": "https://dev.azure.com/fabrikam/_apis/wit/workItems/12"
}

Get work item with asOf parameter

Sample request

GET https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_apis/wit/workitems/564?asOf=2017-12-21T19:42:54.230Z&api-version=7.1

Sample response

{
  "id": 564,
  "rev": 4,
  "fields": {
    "System.AreaPath": "MyAgilePrj2",
    "System.TeamProject": "MyAgilePrj2",
    "System.IterationPath": "MyAgilePrj2\\Iteration 0",
    "System.WorkItemType": "Task",
    "System.State": "Proposed",
    "System.Reason": "New",
    "System.AssignedTo": {
      "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"
    },
    "System.CreatedDate": "2017-12-16T00:46:58.01Z",
    "System.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"
    },
    "System.ChangedDate": "2017-12-16T00:49:08.81Z",
    "System.ChangedBy": {
      "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"
    },
    "System.Title": "t1.3",
    "Microsoft.VSTS.Common.StateChangeDate": "2017-12-16T00:46:58.01Z",
    "Microsoft.VSTS.Common.Priority": 2,
    "Microsoft.VSTS.CMMI.Blocked": "No",
    "Microsoft.VSTS.Common.Triage": "Pending",
    "Microsoft.VSTS.CMMI.TaskType": "Planned",
    "Microsoft.VSTS.CMMI.RequiresReview": "No",
    "Microsoft.VSTS.CMMI.RequiresTest": "No"
  },
  "_links": {
    "self": {
      "href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/564/revisions/4"
    },
    "workItemRevisions": {
      "href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/564/revisions"
    },
    "parent": {
      "href": "https://dev.azure.com/fabrikam/_apis/wit/workItems/564"
    }
  },
  "url": "https://dev.azure.com/fabrikam/_apis/wit/workItems/564/revisions/4"
}

Definitions

Name Description
ReferenceLinks

The class to represent a collection of REST reference links.

WorkItem

Describes a work item.

WorkItemCommentVersionRef

Represents the reference to a specific version of a comment on a Work Item.

WorkItemExpand

The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }

WorkItemRelation

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.

WorkItem

Describes a work item.

Name Type Description
_links

ReferenceLinks

Link references to related REST resources.

commentVersionRef

WorkItemCommentVersionRef

Reference to a specific version of the comment added/edited/deleted in this revision.

fields

object

Map of field and values for the work item.

id

integer

The work item ID.

relations

WorkItemRelation[]

Relations of the work item.

rev

integer

Revision number of the work item.

url

string

WorkItemCommentVersionRef

Represents the reference to a specific version of a comment on a Work Item.

Name Type Description
commentId

integer

The id assigned to the comment.

createdInRevision

integer

[Internal] The work item revision where this comment was originally added.

isDeleted

boolean

[Internal] Specifies whether comment was deleted.

text

string

[Internal] The text of the comment.

url

string

version

integer

The version number.

WorkItemExpand

The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }

Name Type Description
all

string

Expands all.

fields

string

Fields work item expand.

links

string

Links work item expand.

none

string

Default behavior.

relations

string

Relations work item expand.

WorkItemRelation

Name Type Description
attributes

object

Collection of link attributes.

rel

string

Relation type.

url

string

Link url.