Reputation: 45
Is there an API endpoint for Azure Devops where I can get all leaf nodes (anything that isn't a folder essentially) for a tree structure? Right now, I loop through the root of the repository, then for recurse over each folder, then each folder within the folder, etc. There isn't really a better way to do it unless there is an API that will return the contents of a repository as a list that I can then filter based on gitObjectType
.
I found this endpoint, but when I specify the root of my repository, it only returns one item.
Again, here is a representation of what my repo looks like:
repo root
-> Folder1
-> File1
-> File 2
-> Folder 2
-> Folder 3
-> File 3
-> File 4
-> File 5
Upvotes: 0
Views: 4807
Reputation: 35194
Is there an API endpoint for Azure Devops where I can get all leaf nodes (anything that isn't a folder essentially) for a tree structure?
To get all files of a repo, you can use the following Rest API to get the tree of the repo: Items - List.
You can set the parameter:recursionLevel=Full
in the Rest API URL and remove the specified path.
For example:
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?recursionLevel=Full&api-version=5.1
It will return all files and gitObjectType.
Upvotes: 1