Search code examples
githubgithub-apigithub-actions

Cannot trigger dispatches from GitHub API


I want to trigger a GitHub Actions workflow manually. Through the docs I found out I can do so through a repository dispatch event.

The problem is that when I hit the API at the /dispatches endpoint, I get the following error:

{
    "message": "Not Found",
    "documentation_url": "https://developer.github.com/v3/repos/#create-a-repository-dispatch-event"
}

I have write access to the repo. I generated myself an access token.

Is the dispatches functionality enabled by default or do I need to "enable" it somehow, so the the /dispatches endpoint becomes available? Either I didn't look well enough, or this is not described in the docs.

I don't know if it makes a difference, but the repo is owned by an organization, not by an individual user.


Solution

  • The problem turned out to be very basic. I was sending the Authorization header with Bearer prefix, before the actual token, whereas I was supposed to send it with token prefix.

    Needless to say, the returned error message is quite misleading.