Skip to content

[Bitbucket] upload/update file in bitbucket server #1080

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Shaked opened this issue Nov 20, 2022 · 2 comments
Closed

[Bitbucket] upload/update file in bitbucket server #1080

Shaked opened this issue Nov 20, 2022 · 2 comments

Comments

@Shaked
Copy link

Shaked commented Nov 20, 2022

According to the documentation about uploading a file, it seems like there is something missing in both of upload_file and update_file methods. I assume that these should have a Content-Type: multipart/form-data header, shouldn't they?

I keep seeing the error message below when I try running the following code:

from atlassian.bitbucket import Bitbucket
b = Bitbucket("http://localhost:7990", token=TOKEN)
b.update_file("COOL","blah1","abcbcbcbc", "ccccccc", "refs/heads/main", "file1.txt", "6147607593f94ede454db5deba7a3ac5549bef3c")

requests.exceptions.HTTPError: 415 Client Error: for url: http://localhost:7990/rest/api/1.0/projects/COOL/repos/blah1/browse/file1.txt

This is how a curl command works:

curl -X PUT -H "Authorization: Bearer $TOKEN" -F content=@/tmp/file.txt  -F 'message=Updated using file-edit REST API' -F branch=main  http://localhost:7990/rest/api/latest/projects/COOL/repos/blah1/browse/README.md

Appending -F sourceCommitId=5e18a05b8e87de4b01e3c07969f0168acacaafba will update the file in case it exists.

Not sure if I'm right or just maybe doing something wrong?

gonchik added a commit that referenced this issue Dec 4, 2022
… issue #1080) (#1092)

* [Bitbucket] Fixed broken update_file and upload_file API calls

* Black formatting

Co-authored-by: Gonchik Tsymzhitov <gonchik.tsymzhitov@gmail.com>
@jnbolito
Copy link
Contributor

jnbolito commented Dec 4, 2022

Hi @Shaked, the above PR fixes this. It should go out in the next release. 😄

@gonchik
Copy link
Member

gonchik commented Feb 24, 2023

Hi @Shaked !
it has been released.
Thank you for your work @jnbolito !

Cheers,
Gonchik Tsymzhitov

@gonchik gonchik closed this as completed Feb 24, 2023
@gonchik gonchik changed the title upload/update file in bitbucket server [Bitbucket] upload/update file in bitbucket server Feb 24, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants