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
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)
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.