Search code examples
github-api

GitHub API - How to add an admin collaborator?


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.


Solution

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