Script Not Sending Webhook

I Want To Send Webhook Through Script But Not Working
Error: HTTP 400 (Bad Request) - Server - EventHandler:39

Idk if it is required but I am using bindable event

Script 1

-- Services
local RS = game:GetService("ReplicatedStorage")
local httpService = game:GetService("HttpService")

-- Folders
local Events = RS.Events

-- Locals
local Webhook = Events.Webhook

----------- Webhook -----------------------------------

local function WebhookSend(webhookPayload)
	local webhookUrl = webhookPayload.webhook
	local fields = webhookPayload.fields

	local Data = {
		["content"] = "",
		["embeds"] = {
			{
				["title"] = webhookPayload.title,
				["description"] = webhookPayload.description,
				["color"] = webhookPayload.color,
				["thumbnail"] = {
					["url"] = webhookPayload.thumbnail
				},
				["fields"] = fields
			}
		}
	}
	local newdata = httpService:JSONEncode(Data)
	local success, result = pcall(function()
		httpService:PostAsync(webhookUrl, newdata)
	end)

	if not success then
		warn(result)
	end
end


Webhook.Event:Connect(WebhookSend)

Script 2

local webhook = {
			webhook = "webhook";
			title = "Donation Detected";
			description = "Donation Detected In "..game.Name;
			color = 0;
			thumbnail = Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420);
			fields = {
				{
					name = "Name",
					value = player.Name,
					inline = true
				},
				{
					name = "UserID",
					value = player.UserId,
					inline = true
				},
				{
					name = "Account Age",
					value = player.AccountAge,
					inline = true
				},
				{
					name = "ProductID",
					value = receipt.PurchaseId,
					inline = true
				},
				{
					name = "Amount",
					value = receipt.CurrencySpent,
					inline = true
				},
				{
					name = "PlaceID",
					value = receipt.PlaceIdWherePurchased,
					inline = true
				}
			}
		}
			
		Events.Webhook:Fire(webhook)

discord has blocked requests made from Roblox due to the high number of webhooks being spammed from roblox. however, you can get around with that by using proxies

It is important to note that exceeding the rate limit for webhook requests could lead to the termination of your discord account.

also, make sure http requests are enabled through game settings

2 Likes

Just wanted to add on to the above response - it’s recommended if you create your own proxy for security reasons. There are a number of tutorials to do so on the DevForum, if I’m not mistaken.

If you’re not willing to spend some money to host your own proxy, then you can try using proxy services like Hyra, although you shouldn’t rely on public services if you’re planning to send information through webhooks for an prolonged period of time.

Hope this helped! :smiley:

Unfortunately, discord has blocked http requests from ROBLOX so you have to use a proxy.

Simply change your webhook URL to hydra.

https://discord.com should be changed to https://hooks.hyra.io and the rest of the webhook the same.