sur*_*dar 6 ruby github github-api octokit
当我尝试创建一个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"
}
Run Code Online (Sandbox Code Playgroud)
还有如何使用github_api或octokit以红宝石的方式完成(因为我无法找到有关创建问题的文档)目前我所做的是使用github_api gem
issues = Github :: Issues.new用户:'user',repo:'repo'它发布到同一个网址(https://api.github.com/repos/repo/user/issues)并再次找不到网页错误.而且我也不知道如何用它发送身份验证
小智 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"
]
)
Run Code Online (Sandbox Code Playgroud)