Basically what I want to do is use Github’s rest API to add a repository to a team within my organization, and add it as the admin role on said repo.
Now I’ve obviously checked github’s documentation on this, which is here: https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#add-or-update-team-repository-permissions but no matter what I try I’m having a lot of trouble with this particular call. I keep getting a 404 when I try and hit this. I’m using python requests to accomplish this, and this is the code snippet in question:
url = f"https://api.github.com/orgs/{owner}/teams/{teamname}/repos/{owner}/{repo}"
headers = {
"Authorization": f"token {token}"
}
params = {
"permission": "Admin"
}
response = requests.post(url, headers=headers, params=params)
Doesn’t work. I get a 404 when I try this.
I wonder if I’m misunderstanding the exact URL I should be using here, It’s odd that I have the owner in there twice, in the document it says “org” for the first one, which makes sense, and then it says “repos/{owner}/{repo}” and I’m not 100% sure what that one is supposed to be.
It also calls it “team_slug.” I’ve looked all over the documentation and can’t find what exactly team_slug means and if it’s different than team name.