github API - 使用curl PUT向团队添加回购 [英] github API - using curl PUT to add a repo to a team

查看:138
本文介绍了github API - 使用curl PUT向团队添加回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在github上向团队添加回购,因此:

I am trying to add a repo to a team on github, thus:

curl -i -u username:password  -X PUT  -d "" https://api.github.com/teams/:team/repos/:user/:repo

(细节遗漏)

非常详尽的文档中指出。

这给出了 500内部服务器错误

Pretty much as indicated in the not so verbose documentation.
This gives a 500 Internal server error.

如果我省略了 -d,它会提供一个 411需要的长度

如果我指定(使用 -H Content-Length: 0 500 错误...

任何线索?

If I leave out the -d"" it gives a 411 "Content-Length required",
if I specify (using -H) "Content-Length: 0": again the 500 error...
Any clues?

答案:API提供了虚假响应,文档在那里不是很好:

:team 是系统分配的数字ID(而不是你给它的名称.. arg!) - 它只能从API查询或从浏览器中查看URL时可用访问团队。多么优雅。

此外,您似乎只能在您的帐户下分配任何 ol'repo,它必须在小组所属的组织中。

获得它将显然需要一些有趣的体操...更多如果我想出来。 GitHub到目前为止的使用情况:(1-10)2。

[edit] Answer: the API was giving spurious responses and the docs are not very good there:
":team" is a numerical id assigned by the system (not the name you gave it .. arg!) - it is available only from an API query or from looking at the url in the browser when you visit the team. How elegant.
Moreover, it does not seem that you can assign just any ol' repo under your account - it must be in the "organization" to which the team belongs.
Getting it there will apparently require some entertaining gymnastics... more if I figure it out. GitHub Usablity rating so far: (1-10) 2.

结论:github上的文档规定:

[edit 2] The conclusion: the documents on github prescribe this:


添加团队repo

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

的工作方式是:

Does not work. What does work is this:

PUT /teams/:id/repos/:org/:repo

替换:user :org (团队所属组织的名称)

Replacing ":user" with ":org" (the name of the "organization" that the team belongs to.

推荐答案

您还需要确保:repo是 repo [name] 字段,而不是 repo [id] 字段。

You also need to make sure that the :repo is the repo["name"] field, NOT the repo["id"] field.

这篇关于github API - 使用curl PUT向团队添加回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆