Items - Get
Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download.
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&api-version=7.1
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&scopePath={scopePath}&recursionLevel={recursionLevel}&includeContentMetadata={includeContentMetadata}&latestProcessedChange={latestProcessedChange}&download={download}&$format={$format}&versionDescriptor.version={versionDescriptor.version}&versionDescriptor.versionOptions={versionDescriptor.versionOptions}&versionDescriptor.versionType={versionDescriptor.versionType}&includeContent={includeContent}&resolveLfs={resolveLfs}&sanitize={sanitize}&api-version=7.1
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
organization
|
path | True |
string |
The name of the Azure DevOps organization. |
repository
|
path | True |
string |
The name or ID of the repository. |
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. |
path
|
query | True |
string |
The item path. |
$format
|
query |
string |
If specified, this overrides the HTTP Accept request header to return either 'json' or 'zip'. If $format is specified, then api-version should also be specified as a query parameter. |
|
download
|
query |
boolean |
Set to true to download the response as a file. Default is false. |
|
include
|
query |
boolean |
Set to true to include item content when requesting json. Default is false. |
|
include
|
query |
boolean |
Set to true to include content metadata. Default is false. |
|
latest
|
query |
boolean |
Set to true to include the latest changes. Default is false. |
|
recursion
|
query |
The recursion level of this request. The default is 'none', no recursion. |
||
resolve
|
query |
boolean |
Set to true to resolve Git LFS pointer files to return actual content from Git LFS. Default is false. |
|
sanitize
|
query |
boolean |
Set to true to sanitize an svg file and return it as image. Useful only if requested for svg file. Default is false. |
|
scope
|
query |
string |
The path scope. The default is null. |
|
version
|
query |
string |
Version string identifier (name of tag/branch, SHA1 of commit) |
|
version
|
query |
Version options - Specify additional modifiers to version (e.g Previous) |
||
version
|
query |
Version type (branch, tag, or commit). Determines how Id is interpreted |
Responses
Name | Type | Description |
---|---|---|
200 OK |
successful operation Media Types: "application/zip", "text/plain", "application/octet-stream", "application/json" |
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.code | Grants the ability to read source code and metadata about commits, changesets, branches, and other version control artifacts. Also grants the ability to search code and get notified about version control events via service hooks. |
Examples
Download |
Get metadata |
Download
Sample request
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items?scopePath=/MyWebSite/MyWebSite/Views/Home/_Home.cshtml&download=true&api-version=7.1
Sample response
{
"count": 1,
"value": [
{
"objectId": "61a86fdaa79e5c6f5fb6e4026508489feb6ed92c",
"gitObjectType": "blob",
"commitId": "23d0bc5b128a10056dc68afece360d8a0fabb014",
"path": "/MyWebSite/MyWebSite/Views/Home/_Home.cshtml",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite/Views/Home/_Home.cshtml?versionType=Branch&versionOptions=None"
}
]
}
Get metadata
Sample request
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items?scopePath=/MyWebSite/MyWebSite/Views/Home/_Home.cshtml&api-version=7.1
Sample response
{
"count": 1,
"value": [
{
"objectId": "61a86fdaa79e5c6f5fb6e4026508489feb6ed92c",
"gitObjectType": "blob",
"commitId": "23d0bc5b128a10056dc68afece360d8a0fabb014",
"path": "/MyWebSite/MyWebSite/Views/Home/_Home.cshtml",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite/Views/Home/_Home.cshtml?versionType=Branch&versionOptions=None"
}
]
}
Definitions
Name | Description |
---|---|
Change |
|
File |
|
Git |
|
Git |
Provides properties that describe a Git commit and associated metadata. |
Git |
|
Git |
Type of object (Commit, Tree, Blob, Tag) |
Git |
|
Git |
This class contains the metadata of a service/extension posting a status. |
Git |
Status context that uniquely identifies the status. |
Git |
State of the status. |
Git |
|
Git |
User info and date for Git operations. |
Git |
Version options - Specify additional modifiers to version (e.g Previous) |
Git |
Version type (branch, tag, or commit). Determines how Id is interpreted |
Identity |
|
Item |
|
Item |
|
Reference |
The class to represent a collection of REST reference links. |
Resource |
|
Version |
The type of change that was made to the item. |
Version |
Specifies whether to include children (OneLevel), all descendants (Full), or None |
ChangeCountDictionary
FileContentMetadata
Name | Type | Description |
---|---|---|
contentType |
string |
|
encoding |
integer |
|
extension |
string |
|
fileName |
string |
|
isBinary |
boolean |
|
isImage |
boolean |
|
vsLink |
string |
GitChange
Name | Type | Description |
---|---|---|
changeId |
integer |
ID of the change within the group of changes. |
changeType |
The type of change that was made to the item. |
|
item |
string |
Current version. |
newContent |
Content of the item after the change. |
|
newContentTemplate |
New Content template to be used when pushing new changes. |
|
originalPath |
string |
Original path of item if different from current path. |
sourceServerItem |
string |
Path of the item on the server. |
url |
string |
URL to retrieve the item. |
GitCommitRef
Provides properties that describe a Git commit and associated metadata.
Name | Type | Description |
---|---|---|
_links |
A collection of related REST reference links. |
|
author |
Author of the commit. |
|
changeCounts |
Counts of the types of changes (edits, deletes, etc.) included with the commit. |
|
changes |
An enumeration of the changes included with the commit. |
|
comment |
string |
Comment or message of the commit. |
commentTruncated |
boolean |
Indicates if the comment is truncated from the full Git commit comment message. |
commitId |
string |
ID (SHA-1) of the commit. |
commitTooManyChanges |
boolean |
Indicates that commit contains too many changes to be displayed |
committer |
Committer of the commit. |
|
parents |
string[] |
An enumeration of the parent commit IDs for this commit. |
push |
The push associated with this commit. |
|
remoteUrl |
string |
Remote URL path to the commit. |
statuses |
A list of status metadata from services and extensions that may associate additional information to the commit. |
|
url |
string |
REST URL for this resource. |
workItems |
A list of workitems associated with this commit. |
GitItem
Name | Type | Description |
---|---|---|
_links |
The class to represent a collection of REST reference links. |
|
commitId |
string |
SHA1 of commit item was fetched at |
content |
string |
|
contentMetadata | ||
gitObjectType |
Type of object (Commit, Tree, Blob, Tag, ...) |
|
isFolder |
boolean |
|
isSymLink |
boolean |
|
latestProcessedChange |
Shallow ref to commit that last changed this item Only populated if latestProcessedChange is requested May not be accurate if latest change is not yet cached |
|
objectId |
string |
Git object id |
originalObjectId |
string |
Git object id |
path |
string |
|
url |
string |
GitObjectType
Type of object (Commit, Tree, Blob, Tag)
Name | Type | Description |
---|---|---|
bad |
string |
|
blob |
string |
|
commit |
string |
|
ext2 |
string |
|
ofsDelta |
string |
|
refDelta |
string |
|
tag |
string |
|
tree |
string |
GitPushRef
Name | Type | Description |
---|---|---|
_links |
The class to represent a collection of REST reference links. |
|
date |
string |
|
pushId |
integer |
|
pushedBy | ||
url |
string |
GitStatus
This class contains the metadata of a service/extension posting a status.
Name | Type | Description |
---|---|---|
_links |
Reference links. |
|
context |
Context of the status. |
|
createdBy |
Identity that created the status. |
|
creationDate |
string |
Creation date and time of the status. |
description |
string |
Status description. Typically describes current state of the status. |
id |
integer |
Status identifier. |
state |
State of the status. |
|
targetUrl |
string |
URL with status details. |
updatedDate |
string |
Last update date and time of the status. |
GitStatusContext
Status context that uniquely identifies the status.
Name | Type | Description |
---|---|---|
genre |
string |
Genre of the status. Typically name of the service/tool generating the status, can be empty. |
name |
string |
Name identifier of the status, cannot be null or empty. |
GitStatusState
State of the status.
Name | Type | Description |
---|---|---|
error |
string |
Status with an error. |
failed |
string |
Status failed. |
notApplicable |
string |
Status is not applicable to the target object. |
notSet |
string |
Status state not set. Default state. |
pending |
string |
Status pending. |
succeeded |
string |
Status succeeded. |
GitTemplate
Name | Type | Description |
---|---|---|
name |
string |
Name of the Template |
type |
string |
Type of the Template |
GitUserDate
User info and date for Git operations.
Name | Type | Description |
---|---|---|
date |
string |
Date of the Git operation. |
string |
Email address of the user performing the Git operation. |
|
imageUrl |
string |
Url for the user's avatar. |
name |
string |
Name of the user performing the Git operation. |
GitVersionOptions
Version options - Specify additional modifiers to version (e.g Previous)
Name | Type | Description |
---|---|---|
firstParent |
string |
First parent of commit (HEAD^) |
none |
string |
Not specified |
previousChange |
string |
Commit that changed item prior to the current version |
GitVersionType
Version type (branch, tag, or commit). Determines how Id is interpreted
Name | Type | Description |
---|---|---|
branch |
string |
Interpret the version as a branch name |
commit |
string |
Interpret the version as a commit ID (SHA1) |
tag |
string |
Interpret the version as a tag name |
IdentityRef
Name | Type | Description |
---|---|---|
_links |
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 |
|
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. |
ItemContent
Name | Type | Description |
---|---|---|
content |
string |
|
contentType |
ItemContentType
Name | Type | Description |
---|---|---|
base64Encoded |
string |
|
rawText |
string |
ReferenceLinks
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. |
ResourceRef
Name | Type | Description |
---|---|---|
id |
string |
|
url |
string |
VersionControlChangeType
The type of change that was made to the item.
Name | Type | Description |
---|---|---|
add |
string |
|
all |
string |
|
branch |
string |
|
delete |
string |
|
edit |
string |
|
encoding |
string |
|
lock |
string |
|
merge |
string |
|
none |
string |
|
property |
string |
|
rename |
string |
|
rollback |
string |
|
sourceRename |
string |
|
targetRename |
string |
|
undelete |
string |
VersionControlRecursionType
Specifies whether to include children (OneLevel), all descendants (Full), or None
Name | Type | Description |
---|---|---|
full |
string |
Return specified item and all descendants |
none |
string |
Only return the specified item. |
oneLevel |
string |
Return the specified item and its direct children. |
oneLevelPlusNestedEmptyFolders |
string |
Return the specified item and its direct children, as well as recursive chains of nested child folders that only contain a single folder. |