Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github API Auth not working with adding a comment on a pull request

According to this other stackoverflow post you are supposed to use the issues API in order to add a comment to a pull request. Seems logical because I want to make a top level comment and only want to include a body of a comment.

Create comment on pull request

I am using the following request with basic auth and have tried both my password and a one time token. We use github enterprise so the host is correct. The Api for comments is here.

https://developer.github.com/v3/issues/comments/#create-a-comment

My request that I am trying looks like this:

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"}

I am getting a 302 response as a redirect

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

Is there another way to do auth or is there something I am doing wrong? The equivalent curl command would probably look something like this

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

like image 370
Scott B Avatar asked Oct 28 '15 00:10

Scott B


People also ask

How do I add a comment to a pull request GitHub?

Adding line comments to a pull request On the pull request, click Files changed. Hover over the line of code where you'd like to add a comment, and click the blue comment icon. To add a comment on multiple lines, click and drag to select the range of lines, then click the blue comment icon.

How do you resolve PR comments?

Resolving conversations You can resolve a conversation in a pull request if you opened the pull request or if you have write access to the repository where the pull request was opened. To indicate that a conversation on the Files changed tab is complete, click Resolve conversation.

How do I comment on a GitHub review?

To add review comments, click the + icon next to the line number. Type your review comment and then click Start Review. When you are finished adding review comments, from the Side Bar you can choose to either submit the comments, approve the changes, or request changes.


1 Answers

We use github enterprise so the host is correct.

True, but the 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
                       ^^^^^^^

So try with https://ghe.megaleo.com/api/v3/repos/mobile/android/pulls/1615/comments

like image 189
VonC Avatar answered Oct 21 '22 08:10

VonC