could someone tell a way to get file contents through rest api in azure devops? I tried in this way but it isnt getting proper results.
Asked
Active
Viewed 2,802 times
0
-
Does this answer your question? [How to download a file in a branch from a Git repo using Azure DevOps REST Api?](https://stackoverflow.com/questions/54228312/how-to-download-a-file-in-a-branch-from-a-git-repo-using-azure-devops-rest-api) – Yan Sklyarenko Jul 27 '21 at 10:57
2 Answers
2
The URL I have posted above works..I had given wrong input for source provider. It should have been TfsGit.

priya
- 391
- 1
- 5
- 24
0
It should be in this format https://dev.azure.com/{organization}/{project}/_apis/sourceProviders/{providerName}/filecontents?api-version=5.0-preview.1
Service endpoint should be TFGit as per the documentation here

cigien
- 57,834
- 11
- 73
- 112
-
1Also found this is working, in case you just need file contents https://dev.azure.com/{{Organization}}/{{ProjectName}//_apis/git/repositories/{{RepoName}}/items?versionDescriptor.version={{BranchName}}&path={{FilePathwithName}}&api-version=5.0 It downloads the content, we need to pipe that to output file or any object based on your programming language. – Sudhakar Mangipudi Jan 11 '22 at 10:22
-
-
2@Mik Provider is the version control service. In my case it is "tfsGit" example: https://dev.azure.com/MyOrganization/MyProject/_apis/sourceProviders/tfsGit/filecontents?repository=repname&path=/directory1/file.txt&api-version=6.0-preview.1 – Sudhakar Mangipudi Feb 10 '22 at 15:27