Forums

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

Send issue attachment to issue using Freshdesk SDK

m_araujo01
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!
March 1, 2019

Hello.

I'm trying to send an attachment from my Freshdesk application to an Jira issue using the following code:

var fileAttachment = { 
file: {
value: attachment,
options: {
filename: file.name,
contentType: null
}

}

};

var optionsAttachment = {
headers: {
'Authorization': 'Basic ' + btoa(jiraUser + ':' + jiraPass),
// 'Content-Disposition': `form-data; name="file"; filename="${file.name}"; Content-Type: ${file.type}`,
'Content-Type': `multipart/form-data; file=@${file.name}`,
'X-Atlassian-Token': 'nocheck'
},

formData: fileAttachment
};

var url = `${jiraUrl}/rest/api/3/issue/${jiraIssueId}/attachments`;
console.log(url);
client.request.post(url, optionsAttachment /*, { headers: optionsAttachment.headers }*/).then(function (dataIssue) {
resolve(dataIssue);
},
function (err) {
reject(err);
});

The client.request.post is a functionality of Freshdesk SDK to make http calls.

Using this code, the file is sent to Jira, but when I open that file, it shows the following error:

erro jira.png

Can anyone help me in this case?

Thank you.

0 answers

Suggest an answer

Log in or Sign up to answer