After launching this part of code I get next error:
function () { [native code] } could not be cloned.
TypeError: function () { [native code] } could not be cloned.
I know that problem is here: form.append("file", "file")
but I don’t know what’s wrong…
Also I’ve tried form.append("file", Buffer.from("file", 'base64'))
And got the same error
Hi @belokurbohdan
did you find a solution for the problem? I am asking because I got the same error when trying to add an attachment to a Jira issue via REST API.
According to the documentation here, this seems somehow possible with this code
// This sample uses Atlassian Forge and the `form-data` library.
// https://developer.atlassian.com/platform/forge/
// https://www.npmjs.com/package/form-data
import api from "@forge/api";
import FormData from "form-data";
const form = new FormData();
form.append('file', fileStream, {knownLength: fileSizeInBytes});
const response = await api.asApp().requestJira('/rest/api/2/issue/{issueIdOrKey}/attachments', {
method: 'POST',
body: form,
headers: {
'Accept': 'application/json',
'X-Atlassian-Token': 'no-check'
}
});
console.log(`Response: ${response.status} ${response.statusText}`);
console.log(await response.json());
Unfortunately, I wasn’t able to get the filestream of my file so far. All my attempts ended with the same error you mentioned.
function () { [native code] } could not be cloned.
TypeError: function () { [native code] } could not be cloned.