Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Redirect GithubAPI返回404,但默认http请求返回301_Redirect_Github Api - Fatal编程技术网

Redirect GithubAPI返回404,但默认http请求返回301

Redirect GithubAPI返回404,但默认http请求返回301,redirect,github-api,Redirect,Github Api,我尝试获取Github存储库信息 首先是一些测试。我有下一个网址: 当我将其粘贴到浏览器时,它会将我重定向到 如果我通过curl尝试第一个链接,它将返回状态301和位置:https://github.com/rendrjs/rendr 我尝试使用GithubAPI获取存储库信息。为此,我们应称之为: https://api.github.com/repos/:owner/:repo 但当我尝试卷曲时,我https://api.github.com/repos/airbnb/rendr 我得到40

我尝试获取Github存储库信息

首先是一些测试。我有下一个网址:

当我将其粘贴到浏览器时,它会将我重定向到

如果我通过curl尝试第一个链接,它将返回状态301和位置:https://github.com/rendrjs/rendr

我尝试使用GithubAPI获取存储库信息。为此,我们应称之为:

https://api.github.com/repos/:owner/:repo

但当我尝试卷曲时,我https://api.github.com/repos/airbnb/rendr 我得到404错误;对于curl-ihttps://api.github.com/repos/rendrjs/rendr 我得到信息和状态200。如果我为使用APIV3添加Accept:application/vnd.github.v3+json头,默认值为beta,我会得到相同的结果


那么,我可以使用GithubAPI和第一个链接以某种方式获取存储库信息吗?我希望至少301像默认http请求一样。

是的,当前GitHub API在重命名后不会重定向存储库资源。您可以考虑使用存储库ID来获取存储库,而不是名称。例如,尝试取回。即使存储库被重命名,获取此资源也应该有效。好的,感谢您的回复,我将尝试其他解决方案。@IvanZuzak有没有办法系统地获取旧名称回购的id?@RayShan对于公共存储库,您可以获取github.com资源而不是api.github.com资源,看看你被重定向到哪里,然后使用这个新名字。@IvanZuzak谢谢,我本来希望不用这么做的,但似乎没有其他选择