问题
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
(specifics left out)
Pretty much as indicated in the not so verbose documentation.
This gives a 500 Internal server error
.
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?
[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.
[edit 2] The conclusion: the documents on github prescribe this:
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
Replacing ":user
" with ":org
" (the name of the "organization" that the team belongs to.
Case closed. Hopefully this helps somebody avoid a similarly entertaining afternoon.
回答1:
You also need to make sure that the :repo is the repo["name"]
field, NOT the repo["id"]
field.
回答2:
For anyone coming across this again... it looks like :org is now the full name and not the ID
回答3:
"The documents on github prescribe this:"
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
Replacing ":user" with ":org" (the name of the "organization" that the team belongs to.
来源:https://stackoverflow.com/questions/7923405/github-api-using-curl-put-to-add-a-repo-to-a-team