Skip to content

Octokit example not working for "Update a webhook configuration for a repository" #9900

Closed
@fabzo

Description

@fabzo

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/rest/reference/repos#update-a-webhook-configuration-for-a-repository

What part(s) of the article would you like to see updated?

The current example code reads as follows:

await octokit.request('PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config', {
  owner: 'octocat',
  repo: 'hello-world',
  hook_id: 42,
  url: 'url'
})

But Octokit will interpret all first level attributes of the options object as configuration parameters if applicable. From my understanding it will take the 'url' attribute from the options object and ignore the request path. See https://github.com/octokit/endpoint.js/blob/master/src/merge.ts#L14 as well as https://github.com/octokit/endpoint.js/blob/master/src/parse.ts#L76

The example resulted in my code trying to send the request to the provided webhook URL instead of the GitHub API.

The working code looks as follows:

await octokit.request('PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config', {
  owner: 'octocat',
  repo: 'hello-world',
  data: {
    hook_id: 42,
    url: 'url'
  }
})

Unfortunately I could not find the location of the code example in the documentation and thus was unable to propose a change directly.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentThis issue or pull request belongs to the Docs Content teamtriageDo not begin working on this issue until triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions