如何使用 Github API 传递带有子文件夹的路径
我正在尝试使用 github rest api 检索一些 blob 信息。正是 http://develop.github.com/p/object.html < strong>blob/show/:user/:repo/:tree_sha/:path
我在请求子文件夹中的文件时遇到问题。
例如:
http://github.com/api/v2/xml/blob/show / 用户 / 存储库 / *tree_shar* /folder/子文件夹/file.htm
不起作用。
:path 应该是什么样子?
I am trying to retrieve some blob information using github rest api. Being exactly http://develop.github.com/p/object.html the blob/show/:user/:repo/:tree_sha/:path
I get problems when requesting a file that is in a sub folder.
for example:
http://github.com/api/v2/xml/blob/show/ user / repository / *tree_shar* /folder/subfolder/file.htm
doesnt work.
how should the :path look?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的请求看起来很好,并且您正确使用了
:path
变量。但你使用了错误的 SHA。您使用的 SHA 来自提交。您需要使用树 SHA。您还需要确保在文件Linkedin/Summary.htm
存在的地方使用树 SHA。正确的 SHA 为:b0215ec2989369ad39f81e11ecdd29ddf2be83c8
完整请求:
https://github.com/api/v2/xml/blob/show/alexanderbeletsky/blog.beletsky.net/b0215ec2989369ad39f81e11ecdd29ddf2be83c8/Linkedin/Summary.htm
编辑:我完全忘了告诉如何获取树 SHA:首先我从 github 上查看了您的存储库:
git clone https://github.com/alexanderbeletsky/blog.beletsky.net.git
然后我检查了
Linkedin/Summary.htm
的最新提交:就在那里是:树b0215ec2989369ad39f81e11ecdd29ddf2be83c8
Your request looks just fine and you were using the
:path
variable correctly. But you used the wrong SHA. The SHA you used is from a commit. You need to use a tree SHA. You also need to make sure to use a tree SHA where the fileLinkedin/Summary.htm
exists. The correct SHA is:b0215ec2989369ad39f81e11ecdd29ddf2be83c8
And the full request:
https://github.com/api/v2/xml/blob/show/alexanderbeletsky/blog.beletsky.net/b0215ec2989369ad39f81e11ecdd29ddf2be83c8/Linkedin/Summary.htm
Edit: I totally forgot to tell how to get the tree SHA: First I checked out your repo from github:
git clone https://github.com/alexanderbeletsky/blog.beletsky.net.git
Then I checked the most recent commit of
Linkedin/Summary.htm
:And there it was:
tree b0215ec2989369ad39f81e11ecdd29ddf2be83c8