Skip to content

Branch protection "ADd user/team/app access restriction" command examples are incorrect #40620

@zihaoyu

Description

@zihaoyu

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/rest/branches/branch-protection?apiVersion=2022-11-28#add-user-access-restrictions
https://docs.github.com/en/rest/branches/branch-protection?apiVersion=2022-11-28#add-team-access-restrictions
https://docs.github.com/en/rest/branches/branch-protection?apiVersion=2022-11-28#add-app-access-restrictions

What changes are you suggesting?

POST /repos/OWNER/REPO/branches/BRANCH/protection/restrictions/[users|teams|apps]

The code examples for the APIs above call for a JSON object

{
  "users|teams|apps": [
    "name1",
    "name2"
  ]
}

However, we will get error in response

gh: Invalid request.

For 'links/12/schema', {"apps" => ["name1"]} is not an array. (HTTP 422)
  "message": "Invalid request.\n\nFor 'links/12/schema', {\"apps\" => [\"name1\"]} is not an array.",
  "documentation_url": "https://docs.github.com/rest/branches/branch-protection#add-app-access-restrictions",
  "status": "422"
}

It turns out that the APIs need an array directly

[
  "name1",
  "name2"
]

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentThis issue or pull request belongs to the Docs Content teamfix-internallyTriggers a workflow to copy the issue internally and close the current issuerestContent related to rest - overview.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions