Sco*_*t B 6 authentication rest curl github-api pull-request
根据这个其他stackoverflow帖子,你应该使用问题API,以便为pull请求添加注释.似乎合乎逻辑,因为我想做一个顶级评论,只想包含一个评论正文.
我使用基本身份验证的以下请求,并尝试了我的密码和一次性令牌.我们使用github企业,因此主机是正确的.评论的Api就在这里.
https://developer.github.com/v3/issues/comments/#create-a-comment
我正在尝试的请求看起来像这样:
POST /repos/mobile/android/issues/1615/comments HTTP/1.1
Authorization: Basic XXXXXXXXXX
Content-Type: application/json
Cookie: logged_in=no
Host: ghe.megaleo.com
Connection: close
User-Agent: Paw/2.2.5 (Macintosh; OS X/10.10.5) GCDHTTPRequest
Content-Length: 33
{"body":"Here is a test comment"}
Run Code Online (Sandbox Code Playgroud)
我作为重定向获得302响应
<html><body>You are being <a href="https://ghe.megaleo.com/login?return_to=https%3A%2F%2Fghe.megaleo.com%2Frepos%2Fmobile%2Fandroid%2Fissues%2F1615%2Fcomments">redirected</a>.</body></html>
Run Code Online (Sandbox Code Playgroud)
还有其他方法可以做身份验证还是我做错了什么?等效的curl命令可能看起来像这样
curl -H "Content-type: application/json" -X POST -u username:password -d '{"body": "Here is a test comment on a pull request"}' https://ghe.megaleo.com/repos/mobile/android/issues/1615/comments
\n\n\n我们使用 github enterprise 所以主机是正确的。
\n
确实如此,但GitHub v3 页面确实提到了:
\n\n\n\n\n请注意,对于 GitHub Enterprise,与所有其他端点一样,您\xe2\x80\x99 需要传入 GitHub Enterprise 端点作为主机名,以及您的用户名和密码:
\n
$ curl https://hostname/api/v3/ -u username:password\n ^^^^^^^\nRun Code Online (Sandbox Code Playgroud)\n\n所以尝试用https://ghe.megaleo.com/api/v3/repos/mobile/android/pulls/1615/comments
| 归档时间: |
|
| 查看次数: |
352 次 |
| 最近记录: |