I am using gh-cli
I want to add outside collaborator to private repository (my-repo-in-org
) in my organization(my-org
)
I can display collaborators using this gh
gh api repos/my-org/myrepo-in-org/collaborators
Based on docs Add a repository collaborator
I tried to add collaborator (collaborator_name
) with push
permission using:
gh api repos/my-org/my-repo-in-org/collaborators/collaborator-name -f '{"permission"="push"}'
But getting:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest"
}
gh: Not Found (HTTP 404)
Any clue how can I do it?
I need to manage multiple repositories with multiple users and want to automate it.
The default http method used when you specify a parameter using -f/--raw-field
is POST
but this call requires PUT
method. You can tell gh to specify the method using -X
or --method
:
gh api repos/{owner}/{repo}/collaborators/{username} -X PUT -f permission='push'
From the documentation :
The default HTTP request method is "GET" normally and "POST" if any parameters were added. Override the method with '--method'.
And in options list :
-X, --method string The HTTP method for the request (default "GET")