REST API を利用して Jira 課題に添付ファイルを追加する方法

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

目的

この記事では、REST API 経由で課題に添付ファイルをアップロードする方法をご説明します。

ソリューション

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.

  • [Headers] セクションで、[Content-Type] と [X-Atlassian-Token] が含まれ、値が共有されていることを確認します。
  • [file] という名前のキーを含め、「File」と入力してシステムのものを選択するか、「Text」と入力して [Body] セクション配下で絶対パス/参照を利用してファイルにアクセスします。
  • 参考スクリーンショット
     


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

お困りですか?


説明 この記事では、REST API 経由で課題に添付ファイルをアップロードする方法をご説明します。
製品Jira
プラットフォームServer
最終更新日 2023 年 7 月 19 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.