0

I'm trying to list all files for a specific branch in a Azure Devops Repo via the API. Anyone knows if this is possible. I only found information about how to list the contents of a repo. However, it's unclear from which branch the info is comming (I could derive it from the content), but that's not the idea...

I'm looking for a way to list the content of a branch on Azure Devops via the API

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30
Insomnia
  • 25
  • 3

1 Answers1

1

You can use the Items - List API to retrieve/download the content of an Azure DevOps repository as follows:

https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items/items?path=/&versionDescriptor[versionOptions]=0&versionDescriptor[versionType]=0&versionDescriptor[version]={branchName}&resolveLfs=true&$format=zip&api-version=5.0&download=true

Replace the placeholders {organization}, {project}, {repositoryId} and {branchName} with your actual values.

P.S.: You can get the RepositoryId from the Repositories - List API.

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30
  • 1
    I can confirm that the solution Bhargavi mentioned above works in an HTTP request. I sent a request without versionDescriptor and branch settings, got a .zip file downloaded. `https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path=/&$format=zip&download=true` Also, I'm trying to figure out how to do this similar thing through SDK. `item = git_client.get_item(repo.id, path="/abc/def/g.txt", download="true")` the returned item has the correct response, but the download option does not work, might be some bug in SDK. – Dylan Wang May 03 '21 at 04:31