Attaching Files in Web Triggers

I have a Forge app with a Web Trigger that wants to attach a file to an issue. I’m aware of the binary files get corrupted issue, but that’s OK because I’m only dealing with text files.
I think this should work:

  const form = new FormData();
  form.append("file", Buffer.from("Hello World!"), {filename: "sample.txt"})

  const response = await api.asApp().requestJira(route`/rest/api/2/issue/AWS-12/attachments`, {
    method: 'POST',
    body: form,
    headers: {
      'Accept': 'application/json',
      'X-Atlassian-Token': 'no-check'

But, I get TypeError: function () { [native code] } could not be cloned.

This has come up before and generally gets referred to this issue, but that’s the binary corruption issue, where as this is a run time error.

Reading through posts it seems like some folks have been able to get it to work on the Custom UI side, but Web Triggers are not that.

If I can’t get this to work, I’m going to have to use Connect, but it would be nice to get a definitive answer before I do.


Hey @SpikeIlacqua! Is it possible that this doesn’t work because buffer still encodes this string in binary format?

Hey, @mszpyra,

I also tried just a string:

form.append("file", "Hello World!", {filename: "sample.txt"});

and using a File:

  const file = new File(
      ["Test content"],
      { type: "text/plain" }

  form.append("file", file, {knownLength: file.size})

All three produce that same “could not be cloned” error.

Definitely open to other ideas, I’d really like to solve this.



Hey @SpikeIlacqua , I asked the team owning this part of the forge to take a look a this thread. They should be able to help.

It seems that we don’t support Form Data in forge runtime. There is issue for this here [FRGE-114] - Ecosystem Jira This issue is currently worked on and it will be fixed in upcoming v2 forge runtime.