Forum Discussion

chamidu_sumanasekara's avatar
chamidu_sumanasekara
Copper Contributor
Nov 13, 2024

Azure GIT - Get repository list by user PAT

Hi 

We are looking for an API or a workaround to get all the repositories by the PAT

ex: assume there is a user whose PAT has access to two organizations 

Is there an API or a workaround to fetch all repositories under those two organizations and projects under them without passing any organization, project as parameters 

  • chamidu_sumanasekara 
    To list all repositories accessible by a PAT across multiple organizations:

    1. List Organizations: Manually specify the organizations (Azure DevOps doesn’t provide an API to list them).

    2. Get Projects in Each Organization: For each organization, use
    GET https://dev.azure.com/{organization}/_apis/projects?api-version=7.1-preview.4

    3.Get Repositories in Each Project: For each project, use
    GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories?api-version=7.1-preview.1

    4. Automate with a Script: Loop through organizations and projects to collect repositories.

    This approach helps you fetch all accessible repositories with a PAT across specified organizations

Resources