Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Open
@je-hal

Description

@je-hal
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.