Github Auth API not working with adding comment to pull request

According to this other stackoverflow post, you should use the problem API to add a comment to the pull request. It seems logical because I want to make a top-level comment and I only want to add a comment body.

Create a comment for pull request

I use the following query with basic auth and tried both my password and a one-time token. We are using github enterprise, so the host is correct. Api for comments here.

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

My query that I'm 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 get 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 any other way to do auth or is there something I am doing wrong? A similar 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

+6
source share
1 answer

We are using github enterprise, so the host is correct.

True, but the GitHub v3 Page mentions :

Please note that for GitHub Enterprise , like all other endpoints, you need to pass the GitHub Enterprise endpoint as the host name, 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

+3
source

All Articles