【发布时间】:2016-01-27 14:47:55
【问题描述】:
根据另一个 stackoverflow 帖子,您应该使用问题 API 来向拉取请求添加评论。似乎合乎逻辑,因为我想发表顶级评论并且只想包含评论正文。
Create comment on pull request
我正在使用带有基本身份验证的以下请求,并尝试了我的密码和一次性令牌。我们使用 github 企业,所以主机是正确的。 cmets 的 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"}
我收到 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>
还有其他方法可以进行身份验证还是我做错了什么?等效的 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
【问题讨论】:
标签: rest authentication curl github-api pull-request