HTTP 400 (Bad request)

Heya! I keep getting a problem when i try to send a message to Discord through a webhook.

Here’s the code :

Report.OnServerEvent:Connect(function(Player,Reason,Type,Text)
	local HttpService = game:GetService("HttpService")
	local WebhookUrl = "my webhook url here"

	local Data = {
		['content'] = "**Report!**",
		['embeds'] = {
			['title'] = "Report from".. Player.Name,
			['description'] = "An Administrator of the game Hide N Seek has reported something.",
			['color'] = 5814783,
			['fields'] = { 
				{
					['name'] = "Type",
					['value'] = Type,
				},
				{
					['name'] = "Username",
					['value'] = "Magickqjdlsjqd"
				},
				{
					['name'] = "Reason",
					['value'] = Reason,
				}
			}
		}
	}

	local FinalData = HttpService:JSONEncode(Data)
	HttpService:PostAsync(WebhookUrl,FinalData)
end)

Hope you can help me!

Could you show the client side? It might be spamming the event multiple times resulting in it spamming HTTP Service. To my understanding you can only send so many requests at once.

That’s because roblox has a 50 characters limit.
(I forgot if it’s roblox or discord)

So either roblox or discord is preventing you from sending more than 50 characters.

So try to reduce your data size as much as possible.

Yeah, that’s what I said. I knew there was a limit but I forgot the amount of messages.

To fix that, I usually wait a bit to post a message to discord.

Hey! This question has been answered multiple times. A quick search will reveal a solution.

As you can see, an HTTP 400 error, in general, means your request is not valid.

Taking a look at your code, it seems you’re sending the embed’s content directly! You should instead wrap it around an embeds array, as shown here, making it look something like this:

{
    embeds = {
        {
            title = "This is an embed"
        }
    }
}

You have to do this webhooks are able to send multiple embeds per message.

1 Like

There’s no character limit at roblox, but there’s 2000 character limit at discord.

Roblox restrictions:

  • Limit of 500 requests a minute (Per server)
  • This service is not allowed to send requests to any of the Roblox websites such as www.roblox.com.

Discord restrictions:

  • 10,000 per 10 minutes
  • 2000 character limit

Please do not post inaccurate information

2 Likes

Are you even putting your channel ID in the script?

they don’t need to put the channel id it’s part of the webhook

No i fire the Remote using the Output.

Yes but i removed the ID while i was writing this topic.

Regardless of whether or not your body is correct, Discord will not let you use their API from Roblox servers making this a waste of time. Once you end up fixing the body of the webhook it will still not work because Discord completely blocked Roblox due to inexperienced (and experienced) developers misusing their services as well as completely disregarding rate limits.

Don’t use Discord to log things like reports. It’s not what it’s for. Use something in your game that moderators can see rather than something off-platform.

3 Likes