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=4.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.versionOptions={versionDescriptor.versionOptions}&versionDescriptor.version={versionDescriptor.version}&versionDescriptor.versionType={versionDescriptor.versionType}&includeContent={includeContent}&api-version=4.1

URI Parameters

Name In Required Type Description
organization
path True
  • string

The name of the Azure DevOps organization.

project
path
  • string

Project ID or project name

repositoryId
path True
  • string

The Id of the repository.

path
query True
  • string

The item path.

scopePath
query
  • string

The path scope. The default is null.

recursionLevel
query

The recursion level of this request. The default is 'none', no recursion.

includeContentMetadata
query
  • boolean

Set to true to include content metadata. Default is false.

latestProcessedChange
query
  • boolean

Set to true to include the lastest changes. Default is false.

download
query
  • boolean

Set to true to download the response as a file. Default is false.

$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.

versionDescriptor.versionOptions
query

Version options - Specify additional modifiers to version (e.g Previous)

versionDescriptor.version
query
  • string

Version string identifier (name of tag/branch, SHA1 of commit)

versionDescriptor.versionType
query

Version type (branch, tag, or commit). Determines how Id is interpreted

includeContent
query
  • boolean

Set to true to include item content when requesting json. Default is false.

api-version
query True
  • string

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

Responses

Name Type Description
200 OK

successful operation

Media Types: "application/zip", "text/plain", "application/octet-stream", "application/json"

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=4.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=4.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

ChangeCountDictionary
FileContentMetadata
GitChange
GitCommitRef

Provides properties that describe a Git commit and associated metadata.

GitItem
GitObjectType

Type of object (Commit, Tree, Blob, Tag)

GitStatus

This class contains the metadata of a service/extension posting a status.

GitStatusContext

Status context that uniquely identifies the status.

GitStatusState

State of the status.

GitTemplate
GitUserDate

User info and date for Git operations.

GitVersionOptions

Version options - Specify additional modifiers to version (e.g Previous)

GitVersionType

Version type (branch, tag, or commit). Determines how Id is interpreted

IdentityRef
ItemContent
ItemContentType
ReferenceLinks

The class to represent a collection of REST reference links.

ResourceRef
VersionControlChangeType

The type of change that was made to the item.

VersionControlRecursionType

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.

committer

Committer of the commit.

parents
  • string[]

An enumeration of the parent commit IDs for 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

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.

email
  • string

Email address of the user performing the Git operation.

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
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
inactive
  • boolean
isAadIdentity
  • boolean
isContainer
  • boolean
profileUrl
  • string
uniqueName
  • string
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

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.