400 error trying to send an embed to Discord

This topic was automatically generated from Slack. You can find the original thread here.

Nicolai Skodt Holmgaard : Hey, so I am trying to set up a Twitter —> Discord Webhook, however every time I try to send an embed, I get an error 400 back. I even copied the Webhook example code on Discord Webhook - Discord Webhooks Guide (the one you refer to), however that didn’t work either. Would anyone have a solution?

It might be worth noting, that I’m using the “Discord Webhook —> Send Message (advanced)” action

Dylan Sather (Pipedream) : would you mind clicking the Share button at the top right of your workflow and share it with dylan@pipedream.com?

Nicolai Skodt Holmgaard : Absolutely, will share with you in a moment

Edit: Should be shared now

Dylan Sather (Pipedream) : thanks. Do you mind if I make a couple of test edits to your workflow?

Dylan Sather (Pipedream) : I’d also like to replay a previously-sent event as a test

Nicolai Skodt Holmgaard : Sure, go for (both of) it. If you want access to the Discord server as well to see the format, I can invite you there as well (It’s a closed private one, where I test it all out)

Dylan Sather (Pipedream) : Take a look at the format now. You actually don’t need the leading "embeds": since we already pass that. Since that was being duplicated, Discord complained, but if you pass just the array of embeds, it should work

Nicolai Skodt Holmgaard : That explains it, thank you very much! I can confirm it works now with the text, now a time for me to take a look at the image attachment

Nicolai Skodt Holmgaard : Thanks a lot for the help , it works out just how I want it to. I have come across another issue however on another workflow, where I am trying to combine a path from Pipedream + some text + another path

The code is as follows:
"image": {
"url": "${event.thumbnail_url}/?_=${steps.trigger.context.ts}"
}

It should basiclly get the thumbnail from Twitch, then add the currenct timestamp so that the image doesn’t cache in Discord

Dylan Sather (Pipedream) : can you try this, instead?

"url": "{{event.thumbnail_url}}/?_={{steps.trigger.context.ts}}"

Nicolai Skodt Holmgaard : Tried it, sadly it only sends it without the image attached. The one at the top was when I tried a completly different method, but that would work in every scenario

Dylan Sather (Pipedream) : could you try a different, test image URL, or actually substitute values for {width} and {height}? I get a 404 when I hit https://static-cdn.jtvnw.net/previews-ttv/live_user_creygames-{width}x{height}.jpg , and I’m curious if Discord won’t display the image in that case

Nicolai Skodt Holmgaard : Good news - it works with a different image (timestamp as ?_=)
Bad news, it doesn’t work with the thumbnail from Twitch since there is no height or width defined (tested using different images)

image.png

Dylan Sather (Pipedream) : you can try adding a Node.js code step in a step prior to the Discord request with something like:

return event.thumbnail_url.replace("{width}", 400).replace("{height}", 400)

Then pass:

"url": "{{steps.nodejs.$return_value}}/?_={{steps.trigger.context.ts}}"

Nicolai Skodt Holmgaard : That worked out perfectly!
Thank you very much for your help!

Dylan Sather (Pipedream) : love it