HTTP400 (Bad Request) error

Script:

local http = game:GetService("HttpService")
local webhookURL = "https://discordapp.com/api/webhooks/787577042346573835/sk_DeX5G88s8NWQu5TCyjUyMbeGBmBnFIdDCx69_UFO2q9oaBCd1HBOVvVbE7c-I2"

local function SendToDiscord(message)
	local data = {
		["contents"] = message
	}
	data = http:JSONEncode(data)
	http:PostAsync(webhookURL,data)
end

SendToDiscord("hello")

I’m trying to make it so that when the script runs, there will be a discord message popping up in my server. However, it keeps saying HTTP400(Bad Request) error. I don’t know what’s wrong, can anyone help me?

1 Like

The correct spelling is “content”, not “contents”

You should also edit out the webhook url from your post, because some people tend to troll with webhooks.

4 Likes

Thanks, Is there anything I should know with this?

2 Likes

You should regenerate your webhook URL, otherwise someone else who sees the link may abuse it.

1 Like

A good site for webhooks and Roblox - Discord requests would be discohook.org.

You can review a preview of your webhooks and also get the script which would be needed to send it (JSON Data).


With this site in mind, you can easily make webhooks/messages and view the JSON data (converting it to lua of course - which is pretty self explanatory) and send them to Discord.

Hope this helped! :smiley:

1 Like

Don’t worry, I made it so that some of the characters are missing and replace weird alphabets. But about the dictionary, is there any more things I can do instead of the content key?

2 Likes

There are tons of things you can do besides Content. You can make any webhook you can think of.

1 Like