gpt4 book ai didi

GitHub API : create a repository from template authenticated as installation

转载 作者:行者123 更新时间:2023-12-03 08:49:53 25 4
gpt4 key购买 nike

我正在尝试通过 GitHub 的 API 为组织从存储库模板创建存储库。 https://api.github.com/repos/{template_org_name}/{template_repo}/generate。我正在尝试使用经过身份验证作为具有组织管理权限的安装的 GitHub 应用程序来执行此操作。我无法成功创建存储库并获得资源无法通过集成访问响应。但是,我可以使用我自己的 GitHub 用户的个人访问 token 通过同一端点创建存储库。我倾向于认为该端点只能作为用户到服务器的请求使用,但没有运气查看文档( https://developer.github.com/v3/repos/#create-repository-using-a-repository-template )。我知道它在技术上是一个测试端点,所以也许这就是我的答案。

我检查了我在请求中也使用了正确的“Accept” header (Accept:application/vnd.github.baptiste-preview+json)。有人对这个端点有运气吗?

最佳答案

这里的答案已经过时了。在每个人都回答这篇文章和我现在的答案之间的某个时刻,GitHub 更新了 API 以允许这样做。

有一个 API 端点提供此功能: https://docs.github.com/en/rest/repos/repos#create-a-repository-using-a-template

模板存储库现在在 API 中有一个 /generate 端点,它允许您发送包含要创建的新存储库详细信息的 JSON 正文。

curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://api.github.com/repos/TEMPLATE_OWNER/TEMPLATE_REPO/generate \
-d '{"owner":"NEW-REPO-OWNER","name":"NEW-REPO-NAME","description":"Repo created from a template","include_all_branches":false,"private":false}'

关于GitHub API : create a repository from template authenticated as installation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59688159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com