octokit.js: 404 Error: "message":"Not Found"
github authentication code, my-token is an user access token with all necessary privileges.
github.authenticate({type: 'oauth', token:`my-token`});
var owner = 'owner';
var repo = 'repo';
github.repos.getReleases({
owner,
repo
}, function(err, res) {
var releases = res.data;
if (releases.length == 0) {
return;
}
var release = releases[0];
var releaseId = release.id;
console.log(release);
});
the code above is working perfectly.
github.pullRequests.getAll({
owner,
repo,
state: 'closed',
sort: 'updated',
direction: 'desc',
});
github.repos.getLatestRelease({ owner, repo});
these 2 above are giving me this errors
[Error: {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}]
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 5
- Comments: 17 (7 by maintainers)
@zeke this is the output in debug mode
@florent1933 and @lsgrep I had a similar issue. Realized that my 2nd call to github api wasn’t getting authenticated. Once I passed in the right authentication keys and values in the headers, all went well.
Not sure how your app is setup but reading through my issue and solution might help.
this should no longer be the case with
@octokit/rest, the full URL is updated now: https://github.com/octokit/rest.js/blob/9003db1701979493dd2130a01a93c1d928b3d023/lib/request/request.js#L65I’m still thinking about that, also considering how things should behave in the browser as it is the next milestone. But probably resolving with the link is the right thing to do.
Yea, this is the crux of it. It keeps me from using the library at all.
I try to stay as close as possible to the REST API, with all its arguable design flaws and leave better higher-level abstractions to higher level libraries like https://github.com/gr2m/octokit-release-asset-upload
But I agree that in this case the implementation is not ideal. Using the API with sth like curl at least returns a stream https://developer.github.com/v3/repos/contents/#get-archive-link. Plus the current implementation wouldn’t even allow to a higher level library that would use that internally.
So yeah, I think your 1st suggestion is the way to go: resolving with the link. Not yet sure if it should just resolve as string or as a JSON object like
{"link": "https://codeload.github.com/badges/shields/legacy.tar.gz/20c29db7a645609defffdb576f51d3156d70d04a"}.I’ll also check in with my fellow octokit maintainers on this one
@florent1933 note that the 404 in your case is because you set
pathPrefixwhich you shouldn’t unless you use GitHub Enterprise. It tries to gethttps://api.github.com/api/v3...and that doesn’t exist. I’ll get back to the original issue once I work more on testsYeah it shows 404 but it’s most likely an authentication issue. I’d go through the examples folder and try running some of the really simple ones that require authentication.