Issue using embeds with discord webhooks (error 400)

Hello!

I’m currently having an issue using Discord webhooks. I am trying to make a modcall request system, however the issue is that it always errors with error 400. I’ve tried looking up how to use embeds within Discord and I followed them so this should work but doesn’t.

I know my webhook isn’t the issue as I’m able to post a standard message (just using content) without an issue, any help?

modcall.OnServerInvoke = function(player, information) --  I am going to add a cooldown later, no worries about that
	local data = {
		['embeds'] = {
			['author'] = {
				['name'] = player.Name;
				['url'] = 'https://www.roblox.com/users/'..player.UserId..'/profile';
				['icon_url'] = 'http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username='..player.Name;
			};
			['description'] = 'test'
		};
	};
	data = httpService:JSONEncode(data)
	httpService:PostAsync(modcallURL, data) -- modcallURL is the webhook link
end

TIA for any help! :smile:

The issue is simple, you didn’t make a proper request
embed

local data = {
    ['embeds'] = {
        {
            ['author'] = {
                ['name'] = player.Name;
                ['url'] = 'https://www.roblox.com/users/'..player.UserId..'/profile';
                ['icon_url'] = 'http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=150&Format=Png&username='..player.Name;
            };
            ['description'] = 'test';
        }
    };
};

This is what you should be doing. The embeds array should contain the embed objects. In your script, it was an embed object itself.

3 Likes

Ah okay, got it. Thanks for that, I wasn’t sure where I was going wrong but now I see the issue.

1 Like