Home > other >  Getting 422 error when trying to get github webhook deliveries using API
Getting 422 error when trying to get github webhook deliveries using API

Time:10-18

I am using the Github API to get the list of deliveries and I am using their API which is working fine for everything except then I try and get the list of deliveries.

Using their code:

const {
    Octokit
} = require("@octokit/core");

const octokit = new Octokit({
    auth: token
})

octokit.request(`GET /repos/my_owner/my_repo/hooks/987654321/deliveries'`, {
            owner: my_owner,
            repo: my_repo,
            hook_id: 987654321,
        }).then(response => console.log(response.data));

This is the error I am getting:

"hook_id", "owner", "repo" are not permitted keys. Error Status: 422

What am I doing wrong. I have used GitHub many times but have not seen such an error.

CodePudding user response:

Assuming you got the code from here (as you didn’t specify in your question), you’ve replaced the curly-braced placeholders in the endpoint URL argument, counter to how Octokit.js actually works. From Octokit.js' README (emphasis mine):

The 1st argument is the REST API route as listed in GitHub's API documentation. The 2nd argument is an object with all parameters, independent of whether they are used in the path, query, or body.

octokit.request(`GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries'`, {
    owner: my_owner,
    repo: my_repo,
    hook_id: 987654321,
}).then(response => console.log(response.data));
  • Related