HTTP 400 (Bad Request) error when trying to send a Discord Embed: What could the problem be?

Hello guys, :wave:
I’m having some problems with my In-Game feedback system. It just stopped working without a reason. Now when i try to send a message with it, I get an HTTP 400 error.
Please notice that this script used to work fine before, so I really don’t get what’s wrong with it.

Here’s my script:

local http = game:GetService("HttpService")
local WebhookURL = "LinkHere"
local filteringFunction = game.ReplicatedStorage.FilteringFunction
local ChatService = game:GetService("Chat")

local GetName = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId)

local stringToFormat = "!%A - %x - %X UTC"
local timestamp = os.time()
local dateandtime = os.date(stringToFormat, timestamp)

function filteringFunction.OnServerInvoke(player, msg)
	local FilteredMessage = ChatService:FilterStringForBroadcast(msg, player) --Filters the message, before sending it to the webhook.

	local Data = 
		{
			["embeds"] = {{
				["author"] = {
					["name"] = GetName.Name,
					["url"] = "https://www.roblox.com/games/" .. tostring(game.PlaceId),
					["icon_url"] = "https://t4.rbxcdn.com/e8db7615a6d2e53bd6e6d6606460beb1",
				},
				["title"] = "Message:",
				--["url"] = "https://www.roblox.com/users/" .. tostring(player.UserId) .. "/profile",
				["description"] = FilteredMessage,
				["type"] = "rich",
				["color"] = tonumber(0x30B699),
				["thumbnail"] = {url = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)},
				["fields"] = {
					--{
					--	["name"] = "Message:",
					--	["value"] = FilteredMessage,
					--	--["inline"] = true
					--},
					{
						["name"] = "Sent by",
						["value"] = tostring(player.Name .. " (https://www.roblox.com/users/" .. player.UserId .. "/profile)"),
						--["inline"] = true
					},
					{
						["name"] = "Time Data",
						["value"] = tostring(dateandtime),
						--["inline"] = true
					}
				}
			}}
		}

	local Embed = http:JSONEncode(Data)

	http:PostAsync(WebhookURL, Embed)
end

What’s the problem in your opinion? How could I fix that?
As always, thanks in advance for your help.

This is a Discord API error, you’re probably sending something in the body wrong. Try printing the value of Embed and see if it has any null, or undefined.
Make sure it fits the Embed object documentation that can be found here.Discord Developer Portal

I found the problem: apparently the “thumbnail content” is not recognised as a valid “link” anymore.
With “thumbnail content” I mean this: ["thumbnail"] = {url = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)}
In fact, replacing it with the User Profile Icon link fixes the webhook: ["thumbnail"] = {["url"] = "https://www.roblox.com/headshot-thumbnail/image?userId=" .. player.UserId .. "&width=150&height=150&format=png"}

Thanks @sloss2003 for helping me fixing it, I would have never found the problem without that Discord API documentation. :grinning_face_with_smiling_eyes:

1 Like