Generate file with Forge web trigger

TLDR; Is the Content-Disposition header supported in web trigger response headers?

I want to return a file from a web trigger call.

Web trigger could be: https://ab6e087a-85df-461e-b8ad-e2484c636ba4.hello.atlassian-dev.net/x1/kxXiKQ38Oyx0-p5fYSAVbEVXiBw

For simplicity let’s assume a simple text file.
I can return the file with the header like this:

headers: {
  "Content-Type": ["text/plain"],            
}

But since web triggers always have the same URL the file name would be kxXiKQ38Oyx0-p5fYSAVbEVXiBw - so I want to return a Content-Disposition header alongside.

headers: {
  "Content-Type": ["text/plain"],
  "Content-Disposition": "attachment, filename='test123.txt'"
}

But this seems to result in HTTP status 424 Failed Dependency and an empty body.

Any ideas? How can we return a file from a forge web trigger?

All header values must be arrays of strings. Try this:

headers: {
  "Content-Type": ["text/plain"],
  "Content-Disposition": ["attachment, filename=test123.txt"]
}

(Also, watch out for quotes in the file name: you probably want a file named just test123.txt.)

I’ve just checked and there is no error message beyond 424 about exactly what went wrong. Sorry about that, we’ll look for ways of improving the situation so you aren’t in the dark.

1 Like

Thanks, @AlexeyKotlyarov this worked!

Yes, better error handling would be very much appreciated. If you point towards a better Dev Experience for Forge, that would be essential.