rest - Github API 身份验证无法在拉取请求上添加评论

标签 rest authentication curl github-api pull-request

根据this other stackoverflow post,您应该使用问题 API 以便向拉取请求添加评论。似乎合乎逻辑,因为我想进行顶级评论并且只想包含评论的正文。

Create comment on pull request

我将以下请求与基本身份验证一起使用,并尝试了我的密码和一次性 token 。我们使用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"}

我收到 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

最佳答案

We use github enterprise so the host is correct.



没错,但是 GitHub v3 page does mention :

Note that for GitHub Enterprise, as with all other endpoints, you’ll need to pass in your GitHub Enterprise endpoint as the hostname, as well as your username and password:


$ curl https://hostname/api/v3/ -u username:password
                       ^^^^^^^

所以试试 https://ghe.megaleo.com/api/v3/repos/mobile/android/pulls/1615/comments

关于rest - Github API 身份验证无法在拉取请求上添加评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33380719/

相关文章:

php - 如何使用 CSRF token 发布到 Laravel API?

api - REST API框架。无效的querystring参数的建议行为

java - 隐藏或删除 REST Web 服务中的路径

rest - URL编码的POST不良做法?

PHP - 使用登录系统保护仅限成员(member)的页面

"already logged in"的 HTTP 状态

php - Joomla 2.5 - 无需密码即可登录用户

r Blastula curl::curl_fetch_memory(url,handle = h)中的错误:MAIL失败:530

swift - 等效的 Swift NSURLSession 或 Alamofire Curl 帖子

c# - 如何从 HttpCall 读取我的自定义 Flurl header