Github API Create Issues return 404 Not found

老子叫甜甜 提交于 2019-12-06 02:16:32

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/28936959/github-api-create-issues-return-404-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!