skip to Main Content

I’m interested in finding out if there’s a pagination feature available in the Azure DevOps API, specifically for listing repositories of a project using the following endpoint:

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

Unfortunately, based on the documentation, it appears that pagination is not supported when listing repositories.

2

Answers


  1. You can try below API request to get the paginated output while listing repositories:-

    My API with top parameter :-

    https://dev.azure.com/sid24desai0738/AzureDevops/_apis/git/repositories?api-version=7.1-preview.1&$top=100
    

    My API with top and skip paramater:-

    https://dev.azure.com/orgName/ProjName/_apis/git/repositories?api-version=7.1-preview.1&$top=10&$skip=10
    

    Powershell request:-

    $PAT = "xxxxxrp36cuhakncvsamfbukleq"
    $OrgName = "orgname"
    $ProjectName = "projecetname"
    $ApiVersion = "7.0"
    
    $services = Invoke-RestMethod -Uri "https://dev.azure.com/orgName/ProjName/_apis/git/repositories?api-version=7.1-preview.1&$top=10&$skip=10" -Method Get -Headers @{Authorization=("Basic {0}" -f [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$PAT")))}
    
    $services.value
    

    Output:-

    enter image description here

    Reference:-

    Azure-devops rest api – pagination and rate limit – Stack Overflow

    Login or Signup to reply.
  2. Unfortunately, based on the documentation, it appears that pagination is not supported when listing repositories.

    Yes, it’s true.

    I used script to create 210 repositories, even with ‘&top=100’ in rest api url, it will still return all repositories.

    enter image description here

    For other rest api, you can refer to the answer here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search