Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a attachment in jira using rest api.

Nagamanickam
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 27, 2023

Hi,

How can I create an attachment in Jira using rest API and can anyone share the code sample using Javascript? 

I have tried both the endpoint below mentioned while using this I'm getting XSRF check failed error.

1) https://konnectify-jira-integration.atlassian.net/rest/api/3/issue/PRJ2-95/attachments

2) https://konnectify-jira-integration.atlassian.net/rest/api/2/issue/PRJ2-95/attachments

Thanks in advance.

 

 

1 comment

Comment

Log in or Sign up to comment
Jehan Bhathena
Community Champion
June 27, 2023

Hi @Nagamanickam ,

I'm using the "Jira Cloud platform REST API" collection from postman.

Adding a attachment using the API from that collection worked correctly. Adding the CURL for the same:

curl --location 'https://<sitename>.atlassian.net/rest/api/3/issue/<issueKey>/attachments' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: Basic <Token>' \
--form '0=@"<LocalFile Path>"'

 Another link I found that may help : https://community.atlassian.com/t5/Jira-questions/xsrf-check-failed-when-create-jira-ticket-via-rest-api/qaq-p/1256085#M397962

TAGS
AUG Leaders

Atlassian Community Events