Binary data file name in webhook response

If I return binary data (in this case a spreadsheet) to a webhook it loses the defined file name. When the file downloads the file name is the “path from the webhook”.xls

Hi Davey,

To use the name of a file for download simply use the “Response to Webhook” node.
Here you only have to add the header “Content-Disposition: attachment; filename=“fname.ext””.


Thanks @BillAlex that corrected the filename, however instead of returning the proper spreadsheet data in the file, it returns the webhook response now.

Are you sure you did use/follow the example from @BillAlex above by configuring the Respond To Webhook node appropriately by setting “Respond With” to “Binary”?

Sorry @Davey, my bad … the response node has the additional header for file name AND an empty header. If you delete the empty header option all is fine.
@jan is this a bug or a feature?

:information_source: I have edit my posted workflow (delete the empty header option).

1 Like

@BillAlex not sure I follow. You say you added a header option but you did not fill it and that broke it? That it stays there even if not filled is supposed to happen. But it should not break anything.

@jan yes. I just ran some tests. If the “Response to Webhook Node” is used, “Response with” is not set to binary and a header with empty name is added, n8n crashes completely (v0.191.1, selfhosted, node 16.14.0, win64). Errormessage in console: TypeError [ERR_INVALID_HTTP_TOKEN]: Header name must be a valid HTTP token [“”]. Test and production mode.

If “Response with” is set to “Binary”, >>{“message”: “Workflow executed sucessfully”}<< is written to the file. n8n does not crash under these circumstances. Error in console: Error with Webhook-Response for execution “XXX”: “Header name must be a valid HTTP token [”“]”