Hi,
I'm trying to alter an existing file on bitbucket using this rest call:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-post
But whenever I change a file which has a +x modifier, it loses it after I run the post command. The file change however does still go through. So I always get a 201 response.
So after the change, I checkout the branch to verify and I get the following result:
diff --git a/ci/build.sh b/ci/build.sh
old mode 100755
new mode 100644
I tried it with and without Content-Disposition, but it neither seem to work.
This is my last attempt:
```
```
Also doing something along the lines of this doesn't seem to work either:
```
url = f"https://api.bitbucket.org/2.0/repositories/{WORKSPACE}/{REPO_SLUG}/src"
m = MultipartEncoder(
fields={
"message": "Add shutdown script + symlink",
"branch": BRANCH,
# destination paths in the repo:
"bin/shutdown.sh": part(
"bin/shutdown.sh",
"shutdown.sh",
b"#!/bin/sh\nhalt\n",
"executable",
),
"README.txt": part(
"README.txt",
"README.txt",
b"README\n", # symlink target path :contentReference[oaicite:3]{index=3}
"link",
),
}
)
resp = requests.post(
url,
data=m,
headers={"Authorization": f"Bearer {ACCESS_TOKEN}", "Content-Type": m.content_type},
timeout=30,
)
```
Any help with some concrete examples would be appreciated.
Hello @laurens_brock
Try asking your question to an AI like ChatGPT. I did and it gave me a very long-winded explanation that you must set the mode on the multipart field, not in headers.
ChatGPT said:
Key point (short answer)
Content-Disposition headers and custom attributes are ignored for file permissions.
The executable bit (+x, mode 100755) is Git metadata, and Bitbucket Cloud will default files uploaded via src to 100644 unless you explicitly set the mode in the multipart form field itself.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.