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