Can’t access/view the attachment after importing CSV file.
Summary
While importing Jira issues using the CSV Import functionality you might experience an issue where the attachments are not viewable/accessible. Instead, HTML error files are downloaded for every attachment showing the download requests are not authenticated.
Environment
This article can be applied to Jira Server and Data Center
Diagnosis
- Can’t access/view the attachment after importing CSV file.
- The attachments are hosted on an instance that is not publicly accessible.
Cause
This is caused by the URLs in the CSV export from the source system pointing to secure resources. So, when the target system runs a CSV import and tries to load the attachment via HTTP/HTTPS, it is redirected to the login page. The CSV importer follows the redirect and grabs the HTML content payload, and saves the attachment file with the correct name, but with contents being HTML payload of the login page.
Solution 1:
In order to fix this issue you need to replace the attachment URL on the exported CSV file as the following:
17/Mar/22 11:19:30;user.name;filename.pdf;https://username:password@jira-honstname/secure/attachment/xxxxx/filename.pdf
instead of
17/Mar/22 11:19:30;user.name;filename.pdf;https://jira-honstname/secure/attachment/xxxxx/filename.pdf
Disclaimer
Storing passwords in a clear, readable file is a security risk. Make sure to clear your username/password immediately from the file once the import is done.When importing issues through a CSV file into Jira using Import issue from CSV, on the field mapping screen, you won't be able to find a certain field to map because it is not shown on the drop-down list. If you face this issue then you can either :
- Edit their respective Create Issue Screen and add the missing fields
- Or you can use External System Import instead
For more details, you can check Missing fields for mapping when importing issues through CSV in Jira document
Solution 2:
Grant 'anonymous' access to the source project so that the import can download the necessary images. You can do this by
- Go to the source project, and Project Settings > Permissions
- Click Actions > Edit Permissions
- Click Edit next to Browse Projects
- Click the Group radio button, and then select 'Anyone on the web'.
- Click Grant.
Disclaimer
This gives the public access to the project to anyone on the web and can create a security risk, so do this at your own risk. Once the import is done, remove the 'anyone on the web' permission from Browse Projects.