HTTP 400 (Bad Request) (Discord Webhook)

  1. What do you want to achieve? I want to make it so that when the button is clicked, it sends it to my discord server.

  2. What is the issue?

  3. What solutions have you tried so far? I have tried to look around the DevForum but no luck. I use a proxy for the webhook.

local StatusCode = script.Parent.Code
local Error = script.Parent.Error
local PlaceId = script.Parent.PlaceId
local ResponseMessage = script.Parent.ResponseMessage

local HttpService = game:GetService("HttpService")
local Webhook = "https://hooks.hyra.io/api/webhooks/------------------"

script.Parent.Submit.MouseButton1Down:Connect(function(player)
	print("Status: ✔")	
	local A = {
		["embeds"] = {{
			["title"] = "`" .. Error.Text .. "` is back up!",
			["description"] = "🟢 **" .. Error.Text .. "** has improved performance.",
			["type"] = "rich",
			["color"] = tonumber(0x00FF24),
			["author"] = {
				["name"] = "Gandhi20's Games",
				["url"] = "https://discord.gg/ZrVpP9YySC",
				["icon_url"] = "https://cdn.discordapp.com/avatars/967423351217881118/ea8d182f38950481364896edf8cfe753.webp?size=96"
			},
			["footer"] = {
				["text"] = "Powered by Gandhi20's Games",
				["icon_url"] = "https://cdn.discordapp.com/avatars/967423351217881118/ea8d182f38950481364896edf8cfe753.webp?size=96"
			},
			["timestamp"] = DateTime.now():ToIsoDate(),
			["fields"] = {
				["name"] = "PlaceId",
				["value"] = "```" .. PlaceId.Text .. "```",
				["inline"] = true
			},
			{
				["name"] = "Status Code",
				["value"] = "```" .. StatusCode.Text .. "```",
				["inline"] = true
			},
			{
				["name"] = "Response Message",
				["value"] = "```" .. ResponseMessage.Text .. "```",
				["inline"] = false
			}
		}}
	}

	local finaldata = HttpService:JSONEncode(A)
	HttpService:PostAsync(Webhook, finaldata)

	script.Parent.Code.Text = ""
	script.Parent.Error.Text = ""
	script.Parent.PlaceId.Text = ""
	script.Parent.ResponseMessage.Text = ""
end)

Error 400 means there’s an error with the code, check to make sure the parameters you’re sending are correct

The error is in line 40 in a localscript

Wait, that means you are using HTTP in localscript?

are u using local script? because http doesnt work on local script iirc, use RemoteEvent after the button is clicked and send it to the serverscript

1 Like

try replacing the webhook variable with this -
https://webhook.lewistehminerz.dev/api/webhooks/ rest of webhook here

No, it’s a Normal Script. ------------

How do I send information from the client to the server tho?

This is what I currently have.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local GreenEvent = ReplicatedStorage:WaitForChild("GreenStatus")
local YellowEvent = ReplicatedStorage:WaitForChild("YellowStatus")
local RedEvent = ReplicatedStorage:WaitForChild("RedStatus")

local HttpService = game:GetService("HttpService")
local Webhook = "https://hooks.hyra.io/api/webhooks/-"

local function GreenStatus(player, Error, PlaceId, ResponseMessage)
	print("✅ | Green Status")	
	local Data =
		{
			["embeds"] = {{
				["title"] = "`" .. Error .. "` is back up!",
				["description"] = "🟢 **" .. Error .. "** has improved performance.",
				["type"] = "rich",
				["color"] = tonumber(0x00FF24),
				["author"] = {
					["name"] = "Gandhi20's Games";
					["url"] = "https://discord.gg/ZrVpP9YySC";
					["icon_url"] = "https://cdn.discordapp.com/avatars/967423351217881118/ea8d182f38950481364896edf8cfe753.webp?size=96";
				},
				["footer"] = {
					["text"] = "Powered by Gandhi20's Games";
					["icon_url"] = "https://cdn.discordapp.com/avatars/967423351217881118/ea8d182f38950481364896edf8cfe753.webp?size=96";
				},
				["timestamp"] = DateTime.now():ToIsoDate(),
				["fields"] = {
					["name"] = "PlaceId";
					["value"] = "```" .. PlaceId .. "```";
					["inline"] = true;
				},
				{
					["name"] = "Status Code";
					["value"] = "```100```";
					["inline"] = true;
				},
				{
					["name"] = "Response Message";
					["value"] = "```" .. ResponseMessage .. "```";
					["inline"] = false;
				}
			}
			}
		}
	wait(1)
	HttpService:PostAsync(Webhook,HttpService:JSONEncode(Data))
end

GreenEvent.OnServerEvent:Connect(GreenStatus)

Make sure the parameters you are sending to the response header are correct.

They are. Let me show you the error that it’s showing now.

I know that there is an error somewhere in the embed section but not sure where…

Not sure if you already did this, but have you turned on the HTTP Services? {Within Settings}

1 Like

its suppose to be jsondecode for the data to be sent to ur discord server

Yes I did. ---------------------

Have you made sure all the formatting is correct? Maybe this post helps: HTTP 400 (Bad Request) error? - #7 by Awesomewebm

The fields key in the embeds is not attached to one table consisting of multiple fields.

		["fields"] = {
            [1] = {
			    ["name"] = "PlaceId",
			    ["value"] = "```" .. PlaceId.Text .. "```",
			    ["inline"] = true
		    },

		    [2] = {
			    ["name"] = "Status Code",
			    ["value"] = "```" .. StatusCode.Text .. "```",
			    ["inline"] = true
		    },

		    [3] = {
			    ["name"] = "Response Message",
			    ["value"] = "```" .. ResponseMessage.Text .. "```",
			    ["inline"] = false
		    }
        }

It looks like you’re using a LocalScript, use a RemoteEvent to the server and put it in a ServerScript, it will work then.