2

I am able to display the attachment from jira using python using issue.fields.attachment

attach_list = issue.fields.attachment
print attach_list
print attach_list[0]
print attach_list[1]

Output :

  [<JIRA Attachment: filename=u'test.xlsx', 
     id=u'525427', 
     mimeType=u'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'>,
   <JIRA Attachment: filename=u'test2.csv', 
     id=u'525515', 
     mimeType=u'application/vnd.ms-excel'> ]

    test.xlsx
    test2.csv

how to retrieve the id from that list . In the above example, I need to retrieve 525427

Please suggest me ?

falsetru
  • 357,413
  • 63
  • 732
  • 636

1 Answers1

3

Just access the id attribute:

attach_list[0].id

If you want id list, use list comprehension:

attach_list = issue.fields.attachment
id_list = [attach.id for attach in attach_list]
falsetru
  • 357,413
  • 63
  • 732
  • 636