3

I'm using probot => https://probot.github.io/

I've been developing a GitHub application that analyses a specific .json file in a repo for changes to date strings. I do this by subscribing to the push event and watching it with a webhook.

I am using request in Node. The issue I am having is that I continually receive a 404 when the hook runs. My code looks like this:

app.on('push', async context => {
    let repoOwner = context.payload.repository.owner.name;
    let repoName = context.payload.repository.name;

    const options = {
      url: `https://api.github.com/repos/${repoOwner}/${repoName}/contents/file.json`,
      headers: { 'User-Agent': 'request' }
    }
    request.get(options, (error, response, body) => {
      console.log(body) // logs {message: 'Not Found', documentation_url:... etc
      })
  })

previously I was not including a user-agent header which was constantly returning a 403 - GitHub's api specifies that you must pass a header. After doing this I am now constantly getting this 404

captainrad
  • 3,760
  • 16
  • 41
  • 74

1 Answers1

4

Possible reasons for a 404:

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Do GitHub apps have a specific auth token? Or would I need to send the current user's auth token? – captainrad Dec 27 '19 at 22:20
  • The user token or your own should be enough. – VonC Dec 27 '19 at 23:10
  • It is a private repo for sure, the app is installed on that repo. I want the app to be able to be authenticated to preform the `get content` call. However I can't figure out how to get the app's auth token. I should note that I am using probot. – captainrad Dec 28 '19 at 00:44
  • 1
    Any Pat (personal Access Token) of any collaborator having access to the private repository would do. – VonC Dec 28 '19 at 07:29