2014-02-19 51 views
5

當我嘗試創建github問題時,它給出的消息未找到答覆。以及如何發送驗證標題。因爲創建問題需要用戶登錄或認證github api v3創建問題消息未找到

curl -X POST -i -d'{「title」:「my-new-repo」,「body」:「我的新問題描述」}'https://api.github.com/repos/barterli/barter.li/issues

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寶石

問題= Github上進行: :Issues.new用戶:'用戶',回購:'回購'它張貼到相同的網址(https://api.github.com/repos/repo/user/issues),並再次找不到頁面錯誤。我也不知道如何發送驗證

+0

切換到octokit客戶= Octokit :: Client.new:登錄=> 'GITHUB_USERNAME',:密碼=> 'GITHUB_PASSWORD' client.create_issue( '用戶/回購', '標題', '體', {:labels =>'label'}) – surendar

+1

如果使用curl,提供用戶名和密碼的最簡單方法是使用'-u '(例如'-u surendar')。 curl然後會問你的密碼,應該是這樣的:http://developer.github.com/v3/#authentication –

回答

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" 
    ] 
)