Webhook to Excel file

@MutedJam thanks for your example workflow. And in the meantime, I found the error. My Webhook Node Respond option was set to ‘When last node finishes’ instead off ‘Using ‘Respond to Webhook’ node’ …

1 Like

Even better, thanks so much for confirming!

Hi @MutedJam one more question remaining;

how can I specify the filename and extension on the download file?

Now it actually comes out as .zip. Changing the extension to .xlsx shows that it is actually an Excel file.

Thanks again and best regards - Dick

You can adjust the webhook path. If you set it to something like myData.xlsx, the file would be called myData.xlsx:

image

Hi @MutedJam Tom, you’re the best !!! Works like a charm. Furthermore, I think that the combination of an intuïtive product with good support via a community is the key to success. Keep up the good work!

2 Likes

@MutedJam on second thought, you probably do not want to have this in your public web hook url. Is there another method, for example passing the filename as a variable in the url?

Thanks again and best regards - Dick

@MutedJam think I found it :slight_smile:

1 Like

On more (hopefully last for this workflow) question:

I try to include an option where the filename can be specified in de url passed to the Webhook, as follows:

attachment; filename="{{$node["Webhook"].json["query"]["filename"]? $node["Webhook"].json["query"]["filename"] : "Export"}}.xlsx"

Unfortunately, this does not appear to work as I then get an xlsx.zip file instead of [filename].xlsx.

Any idea what I might be doing wrong?

Hi @dickhoning, I tried this out on my end but would still get the XLSX file when setting the content-disposition header using your expression.

Can you confirm which browser you were using when running into this and share a screenshot of the binary tab of your Respond to Webhook node like below? I am especially interested in the mime type your file has.

@MutedJam when I tried this morning, it worked. Don’t know what changed … shoot me!

1 Like

@MutedJam although this now works fine with Safari on macOS, when I call the same webhook via Chrome, I get 82be0ea4-1c84-4c01-8059-7a03d2260bad.zip instead of Export.xlsx

@MutedJam forgot to send you this …

Looks like in your latest screenshot the content-disposition header you were previously setting is missing, meaning the filename defaults to the webhook path again.

Once I added the header, the file had the expected name on Chrome for me:

Could you verify this on your end?

I think I finally figured out what was wrong. I added the extra ‘content-disposition’ header to the webhook node instead of to the respond to webhook node. Everything now works fine in Safari on macOS, but the filename still defaults to the webhook path when I call this workflow via Chrome on macOS.

Hi @dickhoning, I player around with this some more today but could not reproduce the behavior in Chrome unfortunately (but I don’t have Mac OS so don’t have the exact environment you have).

Maybe there’s a fellow Mac user in the community who could chip in on this, let’s see :crossed_fingers:

@MutedJam thanks very much. I really appreciate you trying to figure this out for me. It’s not really a huge problem right now, as I’m going to use this workflow as a micro service and it looks like it’s working fine when I test this in Postman. Funny though that it works fine in macOS Safari and not Chrome, as this is normally the other way around :grin:

By the way; do you know of the top of your head if there are alternatives for content-disposition attachment; filename … ?

@MutedJam I’ve advanced one step … just added and header with content-type application/vnd.ms-excel to my Respond to Webhook node and now I’m getting 82be0ea4-1c84-4c01-8059-7a03d2260.xlsx instead of .zip via Chrome. So the exention now is correct … one down, one left to go :grin:

@MutedJam just found the last problem … there was a space in front of attachment, etc. Safari and Postman apparently can cope with this and Chrome can not. So long story short; problem solved and workflow 100%.

Enjoy your weekend!!!

1 Like

Woah, I would not have guessed that! But that easily explains why I couldn’t see this on my end.

Thanks so much for sharing and have a great weekend as well!

just in case somebody is interested, this is the final code for a simple workflow that I use as a micro service to convert a simple (/flat) JSON array to an Excel file …

2 Likes