octokit.js: Create a webhook, not found response.

I’m trying to create a webhook using the watchEvent and repos.createHook function and I keep getting notFound error.

  github.repos.createHook({
    user: "reggi",
    repo: "stellar-hooks",
    name: "watch",
    active: true,
    events: [
      "user"
    ],
    config: {
      url: "http://requestb.in/1bcs4pn1",
    }
  }, function(err, gres) {

  });
});

I’m getting a not found error:

{ [Error: {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}]

Also tried something simpler, and it’s not working either.

  github.repos.createHook({
    user: "reggi",
    repo: "stellar-hooks",
    name: "push",
    active: true,
    config: {
      url: "http://requestb.in/1bcs4pn1",
    }
  }, function(err, gres) {

  });

Any ideas?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 20 (1 by maintainers)

Most upvoted comments

The access token should have admin:repo_hook scope . Otherwise it will throw a 404

The Amazon CodePipeline service currently can not create GitHub web hooks. It also reports the 404 response. In this case I am not calling the API myself, just choosing from drop-down lists in the AWS console.

There’s a big problem and a ton of confusion around hook names and events.

Here are the parameters for “Create a hook”.

Name - Required. The name of the service that is being called. (See /hooks for the list of valid hook names.)

Events - Determines what events the hook is triggered for. Default: [“push”]

That /hooks is a list of random services that use hooks. It really doesn’t make any sense why I’d need to use any of those as the name.

Hook Name v.s Events

In the watchEvent doc it specifically says “Hook name” watch. Then I found a list of actual “events” and watch is in that as well. This leads me to believe that watch is not a Hook name it’s an event.

I think that the valid Hook name should be web just like in every example in the Hooks documentation.

The correct request should be:

  github.repos.createHook({
    user: "reggi",
    repo: "stellar-hooks",
    name: "web",
    active: true, 
    events: [
      "watch"
    ],
    config: {
      url: "http://requestb.in/1bcs4pn1",
      content_type: "json"
    }
  });

But it doesn’t work 😢