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
18 changes: 13 additions & 5 deletions atlassian/service_desk.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,19 @@ def attach_temporary_file(self, service_desk_id, filename):
experimental_headers["X-Atlassian-Token"] = "no-check"

with open(filename, "rb") as file:
result = (
self.post(path=url, headers=experimental_headers, files={"file": file})
.json()
.get("temporaryAttachments")
)
# bug https://github.com/atlassian-api/atlassian-python-api/issues/1056
# in advanced_mode it returns the raw response therefore .json() is needed
# in normal mode this is not needed and would fail
if self.advanced_mode:
result = (
self.post(path=url, headers=experimental_headers, files={"file": file})
.json()
.get("temporaryAttachments")
)
else:
result = self.post(path=url, headers=experimental_headers, files={"file": file}).get(
"temporaryAttachments"
)
temp_attachment_id = result[0].get("temporaryAttachmentId")

return temp_attachment_id
Expand Down