Discord webhook HTTP 400 (Bad Request)

Hello, I have this HTTP 400 (Bad Request) error, and I don’t know how to fix it, I’m new to webhooks.
I have searched numerous posts but none were a help to me.
I also dont think that discord is denying it, its just an embed.

local url = ""

local http = game:GetService("HttpService")


game.Players.PlayerAdded:Connect(function()
	
	local data = {
		['Embeds'] = {{
			['title'] = "test",
			['description'] = "test"
		}}
	}
	local finaldata = http:JSONEncode(data)
	--error--
	http:PostAsync(url, finaldata)
        --error--
end)

errors:
16:14:01.733 HTTP 400 (Bad Request) - Server - Script:15
16:14:01.733 Stack Begin - Studio
16:14:01.733 Script ‘ServerScriptService.Script’, Line 15 - Studio - Script:15
16:14:01.733 Stack End

1 Like

The following code that sends an embed using a Discord webhook should work properly. You should also ensure that you have HTTP Requests enabled in the Game Settings.

local url = "URL_LINK_HERE"
local http = game:GetService("HttpService")

game.Players.PlayerAdded:Connect(function()
    local data = {
	    ['embeds'] = {{
			title = "Your title here",
			description = "Your description here"
		}}
	}
	
    local finalData = http:JSONEncode(data)
	http:PostAsync(url,finalData)
end)
3 Likes

You defined the field as Embeds with a capital E, but it is supposed to be embeds with a lowercase e.

3 Likes

Do not post your webhook here. Anyone can use it for malicious purposes, since it’s out on the web now. Delete and regenerate the link.

4 Likes
local HS = game:GetService("HttpService")
local WebhookURL = "https://discordapp.com/api/webhooks/xxxxxx/xxxxxxx"
--Replace your link with the link in the Quotes.

local MessageData = {
	["content"] = "Hoi, Test Message arrived!"
}

MessageData = HS:JSONEncode(MessageData)
--We used JSONEncode to convert the Lua Table into a Json String 

HS:PostAsync(WebhookURL,MessageData)

if you want to make a embed replace your data to this.

local data = 
	{
		["content"] = "",
		["embeds"] = {{
			["title"] = "__**Ultimate Title**__",
			["description"] = "blah blah",
			["type"] = "rich",
			["color"] = tonumber(0xffffff),
			["fields"] = {
				{
					["name"] = "__Title__",
					["value"] = "hi",
					["inline"] = true
				},
				{
					["name"] = "__Title__",
					["value"] = "hi",
					["inline"] = true
				}
			}
		}}
	}

I hope its gonna help you!

1 Like

Yeah I was going to remove it but i forgot

1 Like

I just checked and yea someone ping everyone 99k times lol, fortunately its a test server with only me in it

1 Like

Seems you solved your issue! If you need any help with discord stuff just message me via forums!

1 Like