How to add an attachment to issue in Forge?

Hi Community!
I’ve tried a lot to upload attachment to jira issue in my forge app.

My forge app recieves base64 encoded file from custom ui function.
Here’s example of my function:

const form = new FormData();
  form.append("file", "file")
  const response = await api.asUser().requestJira(route`/rest/api/2/issue/${issueId}/attachments`, {
    method: 'POST',
    body: form,
    headers: {
      'Accept': 'application/json',
      'X-Atlassian-Token': 'no-check',

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

1 Like