Skip to content

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

Closed
@Shaked

Description

@Shaked

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions