如何在没有身份验证的情况下获取项目的公共摘要?

时间:2020-01-29 15:15:07

标签: gitlab-api

我可以浏览项目的公共摘要,而无需进行身份验证,例如:https://gitlab.com/Boiethios/someproject/snippets

因此,我希望通过公共API访问此信息。但是,V4 API不允许这样做:GET https://gitlab.com/api/v4/projects/6165269/snippets返回401

我该怎么做?

1 个答案:

答案 0 :(得分:0)

最新的gitlab API使用GraphQL。

要获取项目的摘要,可以执行以下请求:

query {
  project(fullPath: "username_or_group/projectname") {
    snippets {
      nodes {
        fileName,
        title,
        blob {
          rawPath
        }
        # You can query some other fields you want
      }
    }
  }
}

可以here对请求进行测试。

该请求必须作为正文发布到网址https://gitlab.com/api/graphql