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

Webhook PostAsync Giving HTTP 400 Error?

I'm trying to setup webhooks that are embeded however I keep getting an HTTP 400 error I'm not quite sure what I'm doing wrong I've tested with multiple discord bot links and they all failed.

local webhook = "https://discordapp.com/api/webhooks/5084692--" -- I cropped this part so its hidden
local color = 13632027
local Data = {
	['username'] = 'Test',
	['embeds'] = {{
		['color'] = color,
		['fields'] = {
			{value = 'Test', inline = true},
			{value = 'Test', inline = true},
			{value = 'Test', inline = false},
			{value = 'Test', inline = false}
		},
		['title'] = 'Test'
	}},
}
Data = game:GetService('HttpService'):JSONEncode(Data)
game:GetService('HttpService'):PostAsync(webhook, Data, Enum.HttpContentType.ApplicationJson)

1 comment

0

Is Http requests enabled?

1 answer

✓ Accepted answer

You have to specify a name for each field, so I set them as 1, 2, 3, and 4 for you.

local webhook = "(your webhook here)"

local color = 13632027
local Data = {
	username = "Test",
	embeds = {
		{
			color = color,
			fields = {
				{name = "1", value = "Test", inline = true},
				{name = "2", value = "Test", inline = true},
				{name = "3", value = "Test", inline = false},
				{name = "4", value = "Test", inline = false}
			},
			title = "Test"
		}
	}
}
pcall(function()
	game:GetService("HttpService"):PostAsync(webhook, game:GetService("HttpService"):JSONEncode(Data))
end)

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