Python GitHub“状态检查” POST未找到错误! (404)

问题描述 投票:0回答:1

answer:“ 如何在github存储库中执行状态检查?” ..

参考文献以下文章:

https://help.github.com/en/github/administering-a-repository/enabling-required-status-checkshttps://developer.github.com/v3/guides/building-a-ci-server/#working-with-statuses

因此,要更新状态检查,我需要创建一个(并同时更新其状态);按照:https://developer.github.com/v3/repos/statuses/#create-a-status ...发出POST到:

/repos/:owner/:repo/statuses/:sha

但是,每当我尝试将有效负载发布到端点url时,我都会得到一个404response.status_code: 404)。NOTE:我正在使用GitHub Web挂钩本身的信息构建URL,即

content['repository']['owner']['login']
content['repository']['name']
content['pull_request']['head']['sha']

JSON有效负载:

payload = { "state": "pending", "description": "The build succeeded!", "context": "continuous-integration/audit-compliance"}

请求

headers = {'Content-Type': 'application/json',
                       'Authorization': "token "+gittokn}
url = https://github.com/api/v3/repos/<OWNER>/<REPO>/statuses/<PR-HEAD-SHA>
response = requests.post(url, headers=headers, json=payload, verify=False)

Response

{'message': 'Not Found', 'documentation_url': 'https://developer.github.com/enterprise/2.18/v3/repos/statuses/#create-a-status'}

使用Curl

curl -Is --user USER:PASS https://github.com/api/v3/repos/<OWNER>/<REPO>/statuses/<PR-HEAD-SHA> | head -1
    HTTP/1.1 200 OK

curl -Is --user USER:PASS https://api.github.com/repos/<OWNER>/<REPO>/statuses/<PR-HEAD-SHA> | head -1
# no result

我要去哪里错了?

可以根据要求提供其他信息; TIA。

github-api pull-request
1个回答
1
投票

在示例中,URL没有v3前缀,下面的模板将为您工作:

https://api.github.com/repos/ORGNAME/REPONAME/statuses/<SHA>

更新后的答案

https://github.com/api/v3/repos/ //状态/..效果很好。

GitHub令牌的权限设置就是问题; Github确实需要修复其异常处理; 404不是!

© www.soinside.com 2019 - 2024. All rights reserved.