我试图使用 githubs api 对拉取请求发表评论,但我得到了标题中显示的错误。我在堆栈溢出中看到的唯一解决方案是json.dumps数据,但这并没有解决我的问题。我可能做错了什么?
这是我的代码
def _pr_comment(self, res, pr_id):
# POST / repos /: owner /:repo / issues /: issue_number / comments
payload = {"body": json.dumps(res)}
header = {'Authorization': 'token TOKEN',
"Accept": "application/vnd.github.+json"}
response_decoded_json = requests.post(
f'https://api.github.com/repos/REPO/Database-System/issues/{pr_id}/comments',
data=payload, headers=header)
response_json = response_decoded_json.json()
print(response_json, response_decoded_json.status_code)
这是我在响应代码旁边收到的完整响应
{'message': 'Problems parsing JSON', 'documentation_url': 'https://developer.github.com/v3/issues/comments/#create-a-comment'} 400
对此的任何帮助将不胜感激!