curl - github API - 使用 curl PUT 向团队添加存储库

标签 curl github put

我正在尝试向 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/

相关文章:

bash - 并行运行多个 curl 命令

reactjs - 如何将 React 应用程序从 Github 部署到 AWS S3 存储桶并设置环境变量 注意 : I didn't push . github 中的 env 文件

angularjs - 将 Angular $http.put 的数据元素的字符串转换为 JSON 对象

php - HTTP PUT 请求 : Passing Parameters with File

node.js - 使用 'superagent' 模块进行 PUT

c++ - 使用 C++ 重置 curl header

php - REST 风格的 PHP : how does it work from client side to server side?

php - 带有 CURL 的 PHP 中的 SOAP 请求

version-control - 如何使用 Git 更新我的目录和其他内容?

java - 编译在 Android Studio 中使用的 GitHub 项目