Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions atlassian/confluence/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,15 +1279,26 @@ def attach_content(
pass

if existing_attachment:
# Update existing attachment using PUT on the specific attachment ID
# Update existing attachment on the specific attachment ID
attachment_id = existing_attachment["id"]
update_path = f"rest/api/content/{attachment_id}"
response = self.put(
path=update_path,
data=data,
headers=headers,
files={"file": (name, content, content_type)},
)
if self.api_version == "1.0":
# older API versions use POST on data path below the child
update_path = f"{path}/{attachment_id}/data"
response = self.post(
path=update_path,
data=data,
headers=headers,
files={"file": (name, content, content_type)},
)
else:
# newer API versions use PUT on a path derived from the attachment ID directly
update_path = f"rest/api/content/{attachment_id}"
response = self.put(
path=update_path,
data=data,
headers=headers,
files={"file": (name, content, content_type)},
)
else:
# Create new attachment using POST
response = self.post(
Expand Down
Loading