How to add an attachment to a JIRA issue using REST API

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Purpose

This article walks through the process of uploading an attachment to an issue via the REST API.

Solution

Option 1: Using Command Line:

curl -D- -u {username}:{password} -X POST -H "X-Atlassian-Token: nocheck" -F "file=@{path/to/file}" http://{base-url}/rest/api/2/issue/{issue-key}/attachments

For more information including error responses, please review our JIRA REST API code: https://docs.atlassian.com/software/jira/docs/api/REST/latest and the specific endpoint add attachment

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:

  • there is is currently no option to change the filename or add any description to the attachment
  • only files that are accessible for the user running the command can be added 
  • only files with local access path can be added using this endpoint

Need more help?


DescriptionThis article walks through the process of uploading an attachment to an issue via the REST API.
ProductJira
PlatformServer
Last modified on Jul 19, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.