How to add an attachment to a Jira Cloud issue using REST API?
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
Adding attachments to Jira issue via REST API endpoint https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post
Diagnosis
When adding attachments via REST API endpoint to Jira issue if the payload or body isn't formatted well, 415 error is thrown
Solution
Option 1: Using Command Line:
1
2
3
4
curl --location --request POST 'https://your-domain.atlassian.net/rest/api/3/issue/TEST-123/attachments'
-u 'email@example.com:<api_token>'
-H 'X-Atlassian-Token: no-check'
--form 'file=@"myfile.txt"'
Option 2: Using GUI-based Tools (Postman)
This can also be achieved using any GUI tools of your preference. Here an example on how to perform the same operation using POSTMAN tool.
Make sure to include "Content-Type", "X-Atlassian-Token" under "Headers" section with values shared.
Make sure to include key named "file" and of type "File" to select the one from system, or "Text" to access files using absolute path/reference under "Body" section.
Attaching the screenshots for reference:
NOTES:
Bear in mind the permission limitations that might be associated with the file based on it's location of the local machine.
Was this helpful?