如何拒绝Python对Bitbucket的pull请求?

2024-04-20 00:02:28 发布

您现在位置:Python中文网/ 问答频道 /正文

如何使用Bitbucket的2.0API通过Python拒绝拉取请求?你知道吗

根据their documentaion,应该是这样的:

import requests
kwargs = {
    'username': MY_BITBUCKET_ACCOUNT,
    'repo_slug': MY_BITBUCKET_REPO,
    'pull_request_id': pull_request_id
}
url = 'https://api.bitbucket.org/2.0/repositories/{username}/{repo_slug}/pullrequests/{pull_request_id}/decline'.format(**kwargs)
headers = {'Content-Type': 'application/json'}
response = requests.post(url, auth=(USERNAME, PASSWORD), headers=headers)

然而,这失败了,因为response.text只是简单地说了一句“坏请求”。你知道吗

类似的代码对我来说也适用于它们的其他API端点,所以我不确定拒绝方法为什么会失败。你知道吗

我做错什么了?你知道吗


Tags: apiidurlbitbucketresponserequestmyusername