How to list the files with content that are in azure repo using REST API

2.8k views Asked by At

I am referring this link. https://learn.microsoft.com/en-us/rest/api/azure/devops/git/items/get?view=azure-devops-rest-6.0

I require assistance in forming the api link for the below scenario.

List all the files (with content) that are in a particular repo with .yml extension.

Please assist

1

There are 1 answers

0
Delliganesh Sevanesan On

The only way to Get the list of Files available in Azure Repo is Rest API call. For this we have to use the PowerShell.

List All Repos

Used to retrieve the Repos

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories?api-version=5.1

# With Optional Parameter
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories?includeLinks={includeLinks}&includeAllUrls={includeAllUrls}&includeHidden={includeHidden}&api-version=5.1

Get Files

It Get the content of Single item. Download parameter is used to check whether we can download the content or not.

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&api-version=5.1

# With Optional Parameter
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&scopePath={scopePath}&recursionLevel={recursionLevel}&includeContentMetadata={includeContentMetadata}&latestProcessedChange={latestProcessedChange}&download={download}&$format={$format}&versionDescriptor.versionOptions={versionDescriptor.versionOptions}&versionDescriptor.version={versionDescriptor.version}&versionDescriptor.versionType={versionDescriptor.versionType}&includeContent={includeContent}&resolveLfs={resolveLfs}&api-version=5.1

You can implement above Api in your PowerShell accordingly. Refer here for how to implement this in PowerShell.