Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

HTTP 400: Bad Request when adding a webhook?

Hi Everyone!

I wanted to make a webhook in my discord server that will take certain text posted by the server in the roblox chat onto a channel in my discord server. Since the text can only be sent through a local script, i use a remote event to tell another script to send the text to the discord server. Here is some of the local script:

local text = {
			["Data"] = player.Name .. " Has Beaten " .. message .. " in " .. timebeaten .. "!" .. extra
		}
local encodedText = http:JSONEncode(text)
game.ReplicatedStorage.Completion:FireServer(encodedText)

Here is how the script takes the event and attempts to post the message in the discord server

http = game:GetService("HttpService")

game.ReplicatedStorage.Completion.OnServerEvent:Connect(function(encodedText)
	http:PostAsync("[the webhook lol]", encodedText)
end)

For some reason, the output is returning "HTTP 400: Bad Request", and it takes me to the PostAsync line. The URL of the webhook is accurate as well, its just not fully seen in the code block. Can someone tell me whats wrong?

Any help is appreciated :)

2 comments

0

make sure you dont add the webhook

1

You should hide your webhook, remember other people could use it and try and falsely get your discord account terminated!

2 answers

You are incorrectly giving data to the webhook. There is no "Data", I believe you meant "content", which is the content of the webhook message.

Also, be careful of your structure because an exploiter could use the remote event to send their own message instead of the actually intended message and that since you are using PostAsync, you cannot see if you've hit the rate limit so be careful if you spam it.

RequestAsync can read for rate limits however.

This discussion is preserved as it was. New answers, comments, and votes are closed.