How to list all the files that are in TFS GIT repo using REST API

azure devops get repository id
tfs api get all repositories
list all repos in azure devops
azure devops git repository url
azure devops api
azure devops list repositories
azure devops list repositories api
how to see all repos in azure devops

All, I am trying to get the list of all the files that are in a particular repo in TFS GIT using REST API. I found the below one but it only display the contents of the specific file name mentioned after "scopePath=/buld.xml", it only display the contents of file build.xml.

But I am trying, only to list all the files that are in a particular repository with out mentioning the particular file name.

Please help me.


You can use the api below:


Repositories, If I change the path to "/", I successfully get a list of items from the specified git repository. I have tried various ways of specifying the path  Git Repositories. Get a list of repositories in a team project. Add a repository to a team project. Delete a repository from a team project. Pull Requests. Complete pull requests; Get a list of pull requests; Create a pull request; Update a pull request; Commits. Get a list of commits; Refs (branches and tags) Get all branches. Create, update, or delete a branch. Pushes

Also that could be achieved using VisualStudioOnline libs (at the date of writing comment it becomes AzureDevOps): Microsoft.TeamFoundationServer.Client, Microsoft.VisualStudio.Services.Client.

First, you need to create access token. Then just use code below:

VssBasicCredential credintials = new VssBasicCredential(String.Empty, "YOUR SECRET CODE HERE");
VssConnection connection = new VssConnection(new Uri(""), credintials);
GitHttpClient client = connection.GetClient<GitHttpClient>();

List<GitRepository> repositories = await client.GetRepositoriesAsync(true); // or use GetRepositoryAsync()
var repo = repositories.FirstOrDefault(r => r.Name == "Some.Repo.Name");

GitVersionDescriptor descriptor = new GitVersionDescriptor()
    VersionType = GitVersionType.Branch,
    Version = "develop",
    VersionOptions = GitVersionOptions.None

List<GitItem> items = await client.GetItemsAsync(repo.Id, scopePath: "/", recursionLevel: VersionControlRecursionType.Full, versionDescriptor: descriptor);

Under the hood it's using the REST API. So if you try the same effect using c# lang, better delegate it to lib.

Git REST API for Azure DevOps Services, Download a File using VSTS REST APIs of how to download a file from a Git repo in VSTS using the REST APIs (I will I will simply highlight the API necessary to download the file and show some example code for doing it. Version of the API to use. This should be set to '5.1' to use this version of the api.

You need to call the items endpoint first, which gives you an objectId (the gitObjectType should be "tree"):


Then call the trees end point to list the objects in the tree:



Azure DevOps Services REST API: Recursive search on a specified , I have also investigated Azure Devops REST API Git repository requests. build with local TFS in pipeline? or just get the source and build with local IDE (e.g build Trying to query work items via OData, specifically an integer list field. The Repository will contain 2 folders (Script and File) and the contents of each folder  Now you should be able to look around the specific API areas like work item tracking or Git and get to the resources that you need. Keep reading to learn more about the general patterns that are used in these APIs. Get a resource or list of resources. Create a resource. Get a list of resources using a more advanced query.

Download a File using VSTS REST APIs – A Developer's Life, Hi, I need to automate some activities by using vsts apis. First part of the task is covered by TfvcHttpClient that allow me to access to the /330519-team-​services/suggestions/16881988-vsts-tfs-rest-api-check-in-changes  Step 1 – create a PAT. To access VSTS through REST API you have many option to authenticate the call, but the easiest one is using PAT (Personal Access Token). If you do no already have a valid PAT you can create one using security page of your account.

Download source locally from Azure Devops GIT repository, I am using the Get Item Contents API call as documented here (https://docs.​​4.1). the file contents with the characters "ÿþ<" inserted at the beginning of the file, Also I've verified that the files I pushed to my git repo on my local machine show  Is it possible to get all the file names from repository using the GitHub API? I'm currently trying to tinker this using PyGithub, but I'm totally ok with manually doing the request as long as it works. My algorithm so far is: Get the user repo names; Get the user repo that matches a certain description??? get repo file names?

Using API to checkin\checkout files to TFVC repos · Issue , charts creating, Work Item Query (WIQ) used 118-121 check-in file types, 175-​177 GitHub repository list, obtaining, with REST API 297-299 reference link 175  Due to technical constraints, we are only able to document API Version 4.1 and newer using this method. We believe the documentation for API Version 4.1 and newer will be easier to use due to this change. If you are working in TFS or are looking for the older versions of REST APIs, you can take a look at the Pre-Version 4.1 REST API documentation.

  • Hello Cece, I tried the one you suggested its not working I used to different API version like 4.0 also still its not working
  • Which version of TFS are you using? What error did you get? I'm testing with VSTS and it works.
  • I am using Version 16.122.27409.2 and its on premise TFS, I am not getting any error but I am not getting what I am looking for. Below is the info I am getting. "count":1,"value":[{"objectId":"id","gitObjectType":"tree","commitId":"ID","path":"/","isFolder":true,"url":"URL/_apis/git/repositories/repodi/items//…"}]}
  • Please double check whether you specify the correct project and repositoryId in the api. I just tested with TFS 16.131.27701.1, it also worked. I've added a screenshot for your reference.
  • Thanks @CeceDong-MSFT - this did help me. I have the same issue as OP - and I will only see the "/" folder. But If i put the file name simply to the URL I am able to get the files (but not able to list them) e.g. .../items/My_Project.sln?versionType=Branch&versionOptions=None