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) Discord webhook error?

I'm working on an app system for my group, I've used webhooks before but now it just errors (HTTP 400 Bad Request) every time. Here's my script:

	local HTTPService = game:GetService("HttpService")
	local Event = game.ReplicatedStorage.Applications
	Event.OnServerEvent:Connect(function(player,key,questions)
		if key == "level-1" then
			local playerdata = {
				pName = player.Name;
				UserId = player.UserId;
				pRank = player:GetRoleInGroup(4851767)
			}
			if playerdata.pRank == "Class - X" or player.Name == "Pizzafireme" then
				local Q1 = questions.Q1
			local Q1A = questions.Q1A
			local Q2 = questions.Q2
			local Q2A = questions.Q2A
			local Q3 = questions.Q3
			local Q3A = questions.Q3A
			local Q4 = questions.Q4
			local Q4A = questions.Q4A
			local Q5 = questions.Q5
			local Q5A = questions.Q5A
			local mainpdata = player.Name.." | "..player.UserId.." | "..player:GetRoleInGroup(4851767)
			local data = {
				embeds = {
					{
						fields = {
							{
								name = "Player Data:",
								value = mainpdata
							};
							{
								name = "Question 1: "..Q1,
								value = Q1A
							};
							{
								name = "Question 2: "..Q2,
								value = Q2A
							};
							{
								name = "Question 3: "..Q3,
								value = Q3A
							};
							{
								name = "Question 4: "..Q4,
								value = Q4A
							};
							{
								name = "Question 5: "..Q5,
								value = Q5A 
							};
						}
					}
				}
			}
		HTTPService:PostAsync(L1, HTTPService:JSONEncode(data))
		end
	elseif key == "level-2" then
		
	elseif key == "level-3" then
			
	end
end)

Thanks.

2 answers

Make sure your website can accept the post request, tokens are in properly, etc. Also, wrap the post request in a pcall function in case you get an error like you just did.

If setting up your own website (connecting to discord(?)) to get information is a bit tricky for you, here's a tutorial on using google spreadsheets as a database. It's nice for handling stuff like this.

Since you are doing polls, another thing you can try is Google Survey - they have their own rest API which means you can send the data from roblox to the site and the results will all be there for you without any extra sorting of the data.

Assuming that you are using a direct web hook to your discord bot (not using a website to communicate with it), you are missing some properties. I believe you must specify at least the title and description properties in order for this to work.

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