Need help with my webhook

Okay, so basically i’m making a ban webhook, and for the life of me i can’t find out whats the error.

Heres the webhook

	local Data = {
			["content"] = "",
			["embeds"] = { 
				{
					["title"] = "Click Here to view player's profile",
					["description"] = "---------------------------------------------",
					["url"] = "https://www.roblox.com/users/"..tonumber(WebhookData[1]).."/profile",
					["color"] = 13379624,
					["fields"] = { 
						{
							["name"] = "Cheater:",
							["value"] = "``"..tostring(game.Players:GetNameFromUserIdAsync(WebhookData[1])).."``",
							["inline"] = true
						}, {
							["name"] = "Moderator:",
							["value"] = "``"..WebhookData[2].."``",
							["inline"] = true
						}, 
						{
							["name"] = "Reason:",
							["value"] = "``"..WebhookData[3].."``",
							["inline"] = true
						}, 
						{
							["name"] = "Banned For:",
							["value"] = "``"..WebhookData[4].."``",
							["inline"] = true
						}, 
						{
							["name"] = "BAN DATE:",
							["value"] = "````",
							["inline"] = true
						} 
					},
					["author"] = {
						["name"] = "Da Hood Rev Trainer"
					},
					["footer"] = {
						["text"] = "Hello",
						["icon_url"] = ""
					},
					["thumbnail"] = {
						["url"] = ""
					}
				} 
			},
			["attachments"] = { }
		}

This is the script where the webhook is ran.

local Webhook = GameModule:RetriveWebhook("Ban", {Arg2, Player.Name, tostring(Arg3), "PERMA_BAN", os.clock()})
			HttpService:PostAsync("https://webhook.lewisakura.moe/api/webhooks/1362765250256048191/F-Ub0CHsHj40067UjCB7tE-IkICTUetJTda2PPIr7aRj63uevcHUP1rmbbeI1jCAaj2r",HttpService:JSONEncode(Webhook))

Thank you

1 Like

First thing you need to do before anything else is go roll your API token because you just leaked it in the URL.

Then it would help to know what the error says? Also you’re using the old method of POST, you should use HttpService:RequestAsync().

Btw you need to enable Http requests for that place before they can be used.

1 Like

Hi, thank you for responding so about the API i was gonna change it after getting the response i needed, the game already has HTTP Requests on and i changed from HttpService:PostAsync() to HttpService:RequestAsync() and the error has changed. The error i had before was “HTTP 400 (Bad Request)” and the error i have now is “Unable to cast to Dictionary” on the RequestAsync line.

1 Like

Found the issue, os.clock was causing the error.

1 Like

400 means your request was malformed, could be something like the json was invalid, or you missed a required field.

RequestAsync isn’t a drop in replacement for PostAsync, you would need to update the data to match. I could have sworn they deprecated PostAsync tho but the docs site says it isn’t so you can switch that back.

I just checked to make sure the shape of the table encodes to correct JSON and it looks like it does as long as your WebhookData array has strings at the first 3 slots. I would go thru what discord is expecting and make sure you’ve got everything, it could be something like the content field can’t be an empty string

2 Likes