Search code examples
githubgithub-api

Github API: List all repos(internal included) from a Github org using API


I am trying to list all the repos(public, internal) within the org that I am the owner of using the below command.

$orgRepos = Invoke-WebRequest -H $headers -Uri "https://api.github.com/orgs/{$orgName}/repos"

There are about 2 public repos and 10+ internal repos but the above command is listing out only the 2 public repos. I went through the documentation and tried all the options as suggested here with type and per_page but nothing seems to help. For headers, I created it using my PAT by giving access to all the permissions.

$headers = @{
      Authorization = "Basic $($token)"
      Accept = "application/vnd.github.v3+json"
}

How do I get to list out the internal repositories?


Solution

  • The issue was with the header. Replacing "basic" with "token" helped solve the issue.

    $headers = @{
          Authorization = "token $($token)"
          Accept = "application/vnd.github.v3+json"
    }
    

    Thanks to the GH support community here. https://github.community/t/list-all-repos-internal-included-from-a-github-org-using-api/177130/8