atlassian-python-api
atlassian-python-api copied to clipboard
Bitbucket Cloud: unable to commit text-only file using rest_client
Hi,
I'm using the following python request, as shown in Bitbucket API doc to commit a file:
url = f"https://api.bitbucket.org/2.0/repositories/{WORKSPACE}/{slug}/src"
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
data = {"newfile.txt": "Contents of the new file", "message": "ABC-123 doing stuff"}
response = requests.post(url, data=data, headers=headers, auth=(username, password))
So far so good, the file gets commited, as expected.
Then, I try doing the same thing using the rest_client provided in atlassian-python-api:
bb_api= Cloud( url=https://api.bitbucket.org/, username=username, password=password, cloud=True)
url = f"repositories/{WORKSPACE}/{slug}/src"
headers = AtlassianRestAPI.form_token_headers
data = {"newfile.txt": "Contents of the new file.", "message": "ABC-123 doing stuff"}
bb_api.post(url, headers=headers, data=data, absolute=False)
And I get a 500 error.
The only difference I could think of between the 2 ways is how the data is encoded. So I tried disabling rest_client's data encoding by commenting it out in line 214:
213: if files is None:
214: -- data = data # None if not data else dumps(data)
215: -- json_dump = None if not json else dumps(json)
And now the file gets successfully commited.
So my question is: is there something I'm doing wrong, or is this a bug?
Thank you