6

当我尝试创建一个 github 问题时,它会给出消息未找到回复。以及如何使用此发送身份验证标头。因为创建问题需要用户登录或验证

curl -X POST -i -d '{"title":"my-new-repo","body":"我的新问题描述"}' https://api.github.com/repos/barterli/barter。李/问题

HTTP/1.1 404 Not Found
Server: GitHub.com
Date: Wed, 19 Feb 2014 07:11:33 GMT
Content-Type: application/json; charset=utf-8
Status: 404 Not Found
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1392797200
X-GitHub-Media-Type: github.beta
X-Content-Type-Options: nosniff
Content-Length: 86
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
X-GitHub-Request-Id: 6A33C772:4DE7:9FBE4E:53045924

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

还有如何以红宝石的方式使用 github_api 或 octokit 来完成(因为我找不到关于用它创建问题的文档)目前我所做的是使用 github_api gem

问题 = Github::Issues.new user: 'user', repo: 'repo' 它发布到相同的 url ( https://api.github.com/repos/repo/user/issues ) 并且再次找不到页面错误. 而且我也不知道如何用它发送身份验证

4

1 回答 1

1

我猜您遇到问题是因为您尝试使用基本身份验证而不是 oauth。这是一个如何使用github api gem来执行此操作的示例。

# Init the github api
github_api = Github.new basic_auth: 'login:password'
github_api.oauth.create scopes: ['repo']

# Creating a PR
github_api.pull_requests.create(user: 'username or org goes here', repo: 'repo name goes here',
                                      title: 'example pr title', body: 'example pr body',
                                      head: 'master', base: 'production')
# Creating an issue
github_api.issues.create(user: 'username or org name goes here', repo: 'repo name goes here',
  title: "Found a bug",
  body: "I'm having a problem with this.",
  assignee: "octocat",
  milestone: 1,
  labels: [
    "Label1",
    "Label2"
  ]
  )
于 2016-06-05T03:35:09.863 回答