Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github API Create Issues return 404 Not found

Tags:

github-api

I am making a request to the below URL- Post https://api.github.com/repos/kvimal/2048/issues With my Token as a header for authorization.

The Curl Request

curl -i -X POST https://api.github.com/repos/kvimal/2048/issues  -d "{title:'hey'}" -H "Authorization: Bearer xxxxxxxxxxxxxxxxxx" -H "Content-Type: application/json"

And GitHub sends a response 404 Not found. I have reade the Documentation and as far as i have observed i am doing it by the github standards. Can anyone Help with this issues?

like image 932
Vimal Avatar asked Mar 09 '15 07:03

Vimal


2 Answers

Go to "Edit personal access token" page, checkout the "Select scopes" session.

Make sure the token has been granted required access right.

I encountered similar case when trying to create public repo with 'Authorization: token ...' header.

like image 188
Beeno Tung Avatar answered Nov 13 '22 10:11

Beeno Tung


As illustrated in this python script, the header should be using 'token' not Bearer'

headers = {
  'Content-Type':'application/json',
  'Authorization': 'token %s' % token,
} 

(That script doesn't use curl, but give an idea of the header)

For curl queries, see this curl POST tutorial:

curl -H "Authorization: token OAUTH-TOKEN"

And the POST message must be complete as well (as in this python script)

issue = {'title': title,
         'body': body,
         'assignee': assignee,
         'milestone': milestone,
         'labels': labels}
# Add the issue to our repository
r = session.post(url, json=issue)

(again, not curl, but gives you an example of the body)

like image 35
VonC Avatar answered Nov 13 '22 09:11

VonC