4

I'm using the github api (v3) to create a repository in an organisation using my account. I am an admin of that organisation. I'm then using the collaborators endpoint to add a collaborator with admin permissions. I'm authenticating with an oauth token that has the 'repos' scope;

PUT /repos/:owner/:repo/collaborators/:username?permission=admin

Which returns a 204 leading me to believe the PUT has been successful. However, when I get the repository collaborators, or view the collaborators using the github UI the user that I have added has only write permission.

If I set the user to be admin via the UI and get the repository collaborators then the user has admin permission. If I do the PUT again, the user reverts back to having only write permissions.

Can anyone suggest what I may be doing wrong here or is this an issue with GitHub API?

Ta.

Jamie Bowen
  • 129
  • 2
  • 8
  • 1
    This does sound suspiciously like an API bug—it might be worth getting in contact with GitHub support, they are usually very responsive! As an alternative possibility, have you tried the Repository Invitations API preview (`Accept: application/vnd.github.swamp-thing-preview+json`)? It sends an invitation rather than adding the collaborator immediately, but it might provide another data point. – kfb Nov 18 '16 at 09:02

1 Answers1

1

The answer here was to include the permission level in the body, rather than as a query param.

Jamie Bowen
  • 129
  • 2
  • 8
  • to complete you i will add command that worked for me `curl -H "Authorization: token YOUR_TOKEN" "https://api.github.com/repos/YOUR_USER_NAME/YOUR_REPO/collaborators/COLLABORATOR_USER_NAME" -X PUT -d '{"permission":"admin"}'` – Wakan Tanka Mar 10 '20 at 14:16