Github API创建问题返回404找不到 [英] Github API Create Issues return 404 Not found
问题描述
我正在请求以下网址- 发表 https://api.github.com/repos/kvimal/2048/issues 以我的令牌作为授权标头.
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.
卷曲请求
curl -i -X POST https://api.github.com/repos/kvimal/2048/issues -d "{title:'hey'}" -H "Authorization: Bearer xxxxxxxxxxxxxxxxxx" -H "Content-Type: application/json"
然后GitHub发送响应404 Not found.我已经阅读了文档,据我所知,我正在按照github标准进行操作.任何人都可以帮助解决这个问题吗?
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?
推荐答案
如此 Python脚本,标头应使用'token
'而不是Bearer
'
As illustrated in this python script, the header should be using 'token
' not Bearer
'
headers = {
'Content-Type':'application/json',
'Authorization': 'token %s' % token,
}
(该脚本不使用curl,但提供了标题信息)
(That script doesn't use curl, but give an idea of the header)
有关卷曲查询,请参见以下卷曲POST教程:
For curl queries, see this curl POST tutorial:
curl -H "Authorization: token OAUTH-TOKEN"
并且POST消息也必须完整(例如在 python脚本中)>
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)
这篇关于Github API创建问题返回404找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!