Skip to content

Commit 1379a2e

Browse files
skropfSimon Kropf
andauthored
Jira ServiceDesk: Fix create attachment (#1121)
* Jira ServiceDesk: Fix create attachment In service_desk.py/attach_temporary_file a check was added to successfully post the request. * Corrected formatting with black of service_desk.py * undid wrong black formatting --------- Co-authored-by: Simon Kropf <simon.kropf@zamg.ac.at>
1 parent 056d379 commit 1379a2e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

atlassian/service_desk.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,19 @@ def attach_temporary_file(self, service_desk_id, filename):
523523
experimental_headers["X-Atlassian-Token"] = "no-check"
524524

525525
with open(filename, "rb") as file:
526-
result = (
527-
self.post(path=url, headers=experimental_headers, files={"file": file})
528-
.json()
529-
.get("temporaryAttachments")
530-
)
526+
# bug https://github.com/atlassian-api/atlassian-python-api/issues/1056
527+
# in advanced_mode it returns the raw response therefore .json() is needed
528+
# in normal mode this is not needed and would fail
529+
if self.advanced_mode:
530+
result = (
531+
self.post(path=url, headers=experimental_headers, files={"file": file})
532+
.json()
533+
.get("temporaryAttachments")
534+
)
535+
else:
536+
result = self.post(path=url, headers=experimental_headers, files={"file": file}).get(
537+
"temporaryAttachments"
538+
)
531539
temp_attachment_id = result[0].get("temporaryAttachmentId")
532540

533541
return temp_attachment_id

0 commit comments

Comments
 (0)