Hello ,
I would like to add attachment to Jira(cloud) issue using AP.request but i got the error 415 , here is my code snippet
function uploadAttachment(issueIdOrKey, fileToUpload) {
var theRequestURL = `/rest/api/3/issue/${issueIdOrKey}/attachments`;
AP.request({
url: theRequestURL,
type: 'POST',
data: {file: fileToUpload},
async: true,
processData: false,
contentType: false,
headers: {
'X-Atlassian-Token': 'no-check',
'Accept': 'application/json'
},
success: function(responseText) {
console.log('Upload success:', responseText);
alert('Attachment uploaded successfully.');
},
error: function(xhr, textStatus, errorThrown) {
console.error('Error uploading attachment:', errorThrown);
alert("Failed to upload attachment. Please try again.");
}
});
}
someone could help please ?