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
Possible reasons for a 404:
"Authorization: token $TOKEN"
)Accept: application/vnd.github.3.raw
" would give you the raw content.