0

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.

https://dev.azure.com/org/project/_apis/sourceProviders/Git/filecontents?serviceEndpointId=&repository=&commitOrBranch=main&path=/&api-version=6.0-preview.1

1

2 Answers 2

2

The URL I have posted above works..I had given wrong input for source provider. It should have been TfsGit.

Sign up to request clarification or add additional context in comments.

Comments

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

3 Comments

Also found this is working, in case you just need file contents 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.
What exactly is {providerName}?
@Mik Provider is the version control service. In my case it is "tfsGit" example: dev.azure.com/MyOrganization/MyProject/_apis/sourceProviders/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.