Blobs - Get Blob

Get a single blob.

Repositories have both a name and an identifier. Identifiers are globally unique, but several projects may contain a repository of the same name. You don't need to include the project if you specify a repository by ID. However, if you specify a repository by name, you must also specify the project (by name or ID).

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/blobs/{sha1}?api-version=5.0
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/blobs/{sha1}?download={download}&fileName={fileName}&$format={$format}&resolveLfs={resolveLfs}&api-version=5.0

URI Parameters

Name In Required Type Description
organization
path True

string

The name of the Azure DevOps organization.

repositoryId
path True

string

The name or ID of the repository.

sha1
path True

string

SHA1 hash of the file. You can get the SHA1 of a file using the "Git/Items/Get Item" endpoint.

project
path

string

Project ID or project 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.

$format
query

string

Options: json, zip, text, octetstream. If not set, defaults to the MIME type set in the Accept header.

download
query

boolean

If true, prompt for a download rather than rendering in a browser. Note: this value defaults to true if $format is zip

fileName
query

string

Provide a fileName to use for a download.

resolveLfs
query

boolean

If true, try to resolve a blob to its LFS contents, if it's an LFS pointer file. Only compatible with octet-stream Accept headers or $format types

Responses

Name Type Description
200 OK

GitBlobRef

successful operation

Media Types: "application/zip", "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

Sample Request

GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/{sha1}?api-version=5.0

Sample Response

{
  "objectId": "61a86fdaa79e5c6f5fb6e4026508489feb6ed92c",
  "size": 1486,
  "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/61a86fdaa79e5c6f5fb6e4026508489feb6ed92c",
  "_links": {
    "self": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/61a86fdaa79e5c6f5fb6e4026508489feb6ed92c"
    },
    "repository": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249"
    }
  }
}

Definitions

Name Description
GitBlobRef
ReferenceLinks

The class to represent a collection of REST reference links.

GitBlobRef

Name Type Description
_links

ReferenceLinks

The class to represent a collection of REST reference links.

objectId

string

SHA1 hash of git object

size

integer

Size of blob content (in bytes)

url

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.