如何使用API从Github Enterprise服务器(自托管服务器)获取组织列表

问题描述 投票:0回答:1

我正在尝试从自托管的 github 企业服务器获取所有组织。

我可以使用

GET https://api.github.com/user/orgs
从 github.com 云版本获取所有组织,但我不知道如何使用自托管版本来做到这一点。我尝试按照本文档中的指南进行操作,但似乎不起作用:https://docs.github.com/en/[email protected]/rest/orgs/orgs#list-organizations

github github-api
1个回答
0
投票

可以通过 GraphQL API 检索企业服务器中的组织列表。没有 REST API 端点来检索此数据。

来源:Github 的 Enterprise GraphQL 文档

您可以使用企业帐户 API 和审核日志 API,它们仅作为 GraphQL API 提供。

这是一个示例 GraphQL 查询,可以检索企业内的组织列表。

query listOrganizationWithinEnterprise($enterprise_slug: String!) {
  enterprise(slug: $enterprise_slug) {
    name
    organizations(first:100){
      nodes{
        name
        ... on Organization{
          login
          name
        }
      }
    }
  }
}

使用变量部分

{'enterprise_slug': 'your_enterprise_name_here'}

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.