Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Webhook PostAsync Giving HTTP 400 Error?

Asked by
H26O 44
3 years ago

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)
0
Is Http requests enabled? User#32819 0 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

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)
Ad

Answer this question