【问题标题】:How to get a single gist from github with GET /gists/:id如何使用 GET /gists/:id 从 github 获取单个要点
【发布时间】:2013-09-20 21:53:49
【问题描述】:

不知何故,我无法从 github 获得一个要点。

假设我想了解以下要点:https://gist.github.com/jrm2k6/6637633

只需复制并粘贴到浏览器的 URL 字段中即可。

使用https://api.github.com/users/jrm2k6,我可以将用户信息获取为json。

使用https://api.github.com/users/jrm2k6/gists,我可以将此用户的所有公共要点列为 json。

但是我如何获得一个特定的要点 GET /gists/:id id = 6637633 就像它在 api 文档中描述的那样:http://developer.github.com/v3/gists/#get-a-single-gist

https://api.github.com/users/jrm2k6/gists/6637633 我应该以 json 格式接收 gist 的内容,但我收到一个错误

{
  "message": "Not Found",
  "documentation_url": "http://developer.github.com/v3"
}

我做错了什么?

解决方案:您不需要 /users/:user。工作:https://api.github.com/gists/6637633

【问题讨论】:

  • 天哪,谢谢!我被 /users/:user 吸引了……所有以前的页面/教程都使用了它。 Stijn,您能否发表您的评论作为答案?
  • 你为什么要尝试获取我的用户资料?

标签: github github-api


【解决方案1】:

所有要点的文档都提到了

GET /users/:user/gists

请注意,单个 gist 的文档中提到了

GET /gists/:id

所以您不需要用户。 https://api.github.com/gists/6637633 会起作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-17
    • 2022-01-05
    • 2012-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多