Add attachment to the issue using REST V2

Sandhya PS
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!
November 19, 2024

I am trying to add an attachment to issue with help of the Restv2 documentation. 

But the request is error out with "Bad request" below is the request :

where as the file_filedata has the binarycontent value of the file 

 

method:POST path:rest/api/2/issue/CECHP-5632/attachments

Content-Type:multipart/form-data

Accept:application/json

accept-encoding:gzip, deflate

Header Parameters:

X-Atlassian-Token:no-check

FormBody Parameters:

file_FileData:Cg0NCrQAAABNPCsaAQAAAP

filename:null

bytes:null

contentType:null

name:null

originalFilename:StormControlEnabled.pcapng

description:null

size:null

uri:null

url:null

empty:null

open:null

 

 

1 answer

0 votes
Jehan Bhathena
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 19, 2024

Hi @Sandhya PS 

I haven't worked with "binarycontent value of the file", but when I use the regular API, to upload the file using the file path, the API works just fine. I couldn't find the parameter "file_FileData" in the documentation either.

Can you try to use the File path directly instead of the binary data here? Also, try to replace "file_FileData" with only "file" when adding the path.

image.png

Reference: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post

Sandhya PS
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!
November 20, 2024

Hi Jehan Bhathena

Thank you for the reply. 

But the file is in the different application like a file which contains the file name and binary content value.

So would need a way to map those value to REST V2

 

Jehan Bhathena
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 20, 2024

So you're trying to upload the attachments directly to Jira from another application?

If Yes, it may not work from what I've tested. You might need to setup a server in between Jira and the other tool, and make a script that can pull images from one place and then push them to another.

Found a few old Threads for this:

https://community.atlassian.com/t5/Jira-questions/Attaching-image-to-Jira-issue-via-Cloud-REST-API-breaks-the/qaq-p/911352

https://community.blueprism.com/t5/Digital-Exchange/Upload-file-to-JIRA-issue-with-Web-API-Services/m-p/96087/highlight/true#M2898

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events