Hello,
I’m trying to add a PDF document as an attachment that I download from my server. I either get the 415, unsupported media type, or the TypeError: function () { [native code] } could not be cloned. error. I have seen this problem on this forum, like here or here. I have even found this, where it was stated that this issue had been fixed already and released in forge/bridge 2.6. I made sure to refresh my project so it would use 2.6. It didn’t resolve my issue unfortunately. I’m using forge/api@2.11.0, forge/resolver@1.4.10, forge/bridge@2.6.1
Note that this code doesn’t use my PDF file, instead a FormData variable:
resolver.define('uploadToTicket', async ({ payload }) => {
const form = new FormData();
form.append('file', 'file');
form.append('fileName', 'test');
form.append('fileName', 'comment');
form.append('minorEdit', 'true');
const result = await api.asUser().requestJira(route`/rest/api/2/issue/${payload.issueKey.issueKey}/attachments`, {
method: 'POST',
body: form,
headers: {
'Accept': 'application/json',
'X-Atlassian-Token': 'no-check',
}
});
if (result.ok) {
console.log("Attachment upload ok");
}
else {
console.log(result);
}
});
I have also tried to download a PDF attachment from a Jira ticket and reupload it, using the REST API response’s text() or arrayBuffer() function, with no success.
Could you help me resolve the issue?
Cheers,
Mark