REST API to download attachment related to issue

Hi,

I am trying to download attachment. I've got url to attachment but I am not sure how to proceed to download attachment from the following url. Could anyone plz provide me the python code.

https://<jira_server>rest/api/2/attachment/266746

1 answer

0 votes

You can use JIRA Python to do this.

Here is my example code:

jira = JIRA(basic_auth=(un, pwd), options={'server': server})

issue = jira.issue(issuekey, fields='summary,comment,attachment')

for attachment in issue.fields.attachment:
	with open('dl-%s' % (attachment.filename), 'wb') as file:
		file.write(attachment.get())

 

This script will cycle through all the attachments on a given issue, and download them one by one to the current directory (prefixing each with the string "dl-").

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in United States

From Atlassian: Confluence Security Advisory - 2019-03-20

Atlassian released a security advisory on 3/20/2019.  The full advisory is here:  https://confluence.atlassian.com/doc/confluence-security-advisory-2019-03-20-966660264.html In a nutshe...

22 views 0 1
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you