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.

Purpose

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

Solution 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

Solution Using GUI based Tools (Postman):

This can also be achieved using any GUI tools of your preference, sharing the useful information 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


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

Was this helpful?

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