Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Code Example in "Add team access restrictions" #1980

Open
1 task done
je-hal opened this issue Dec 13, 2022 · 4 comments
Open
1 task done

Correct Code Example in "Add team access restrictions" #1980

je-hal opened this issue Dec 13, 2022 · 4 comments

Comments

@je-hal
Copy link

je-hal commented Dec 13, 2022

Code of Conduct

What article on docs.github.com is affected?

Add team access restrictions

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

@je-hal je-hal added the content label Dec 13, 2022
@welcome
Copy link

welcome bot commented Dec 13, 2022

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@cmwilson21
Copy link

@je-hal Thanks so much for opening an issue! I'll triage this for the team to take a look 👀

@docubot
Copy link

docubot commented Dec 13, 2022

Thank you for opening this issue! Changes to the REST API schema can be requested in github/rest-api-description. I will transfer your issue over to that open source repo.

@docubot docubot transferred this issue from github/docs Dec 13, 2022
@je-hal
Copy link
Author

je-hal commented Feb 20, 2023

Any updates here? 👋 I'd already be happy if someone could confirm that there is something wrong with the example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants