我正在尝试向 github 上的团队添加一个 repo,因此:
curl -i -u username:password -X PUT -d "" https://api.github.com/teams/:team/repos/:user/:repo
(具体情况略去)几乎就像不那么冗长的文档中所指出的那样。
这给出了
500 Internal server error
.如果我省略了
-d""
它给出了 411 "Content-Length required"
,如果我指定(使用
-H
)"Content-Length: 0"
: 又是 500
错误...有什么线索吗?
[编辑] 回答:API 给出了虚假的响应,并且那里的文档不是很好:
“
:team
”是系统分配的数字 ID(不是您给它的名称.. arg!) - 它只能通过 API 查询或在您访问团队时在浏览器中查看 url 获得。多么优雅。此外,您似乎不能在您的帐户下分配任何 ol' repo - 它必须在团队所属的“组织”中。
到达那里显然需要一些有趣的体操......如果我弄清楚的话。迄今为止的 GitHub 可用性评分:(1-10) 2。
[编辑 2] 结论:github 上的文档是这样规定的:
Add team repo
In order to add a repo to a team, the authenticated user must be an owner of the org that the team is associated with.
PUT /teams/:id/repos/:user/:repo
不起作用。什么工作是这样的:PUT /teams/:id/repos/:org/:repo
将“:user
”替换为“:org
”(团队所属“组织”的名称。案件结案。希望这有助于某人避免一个同样有趣的下午。
最佳答案
您还需要确保 :repo 是 repo["name"]
字段,而不是 repo["id"]
field 。
关于curl - github API - 使用 curl PUT 向团队添加存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7923405/