Open
Description
Code of Conduct
- I have read and agree to the GitHub Docs project's Code of Conduct
What article on docs.github.com is affected?
What part(s) of the article would you like to see updated?
The code sample is not working.
Currently it suggests to add a JSON object '{"teams":["justice-league"]}'
in the body of the HTTP Request:
curl \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/teams \
-d '{"teams":["justice-league"]}'
However, it is described in the parameter description that an array is expected. That's why you end up with the following error message if you follow the code sample:
{ "message": "Invalid request.\n\nFor 'links/9/schema', {\"teams\"=>[\"justice-league\"]} is not an array.", "documentation_url": "https://docs.github.com/rest/branches/branch-protection#add-team-access-restrictions" }
The correct code sample would be:
curl \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/teams \
-d '["justice-league"]'
Additional information
No response