Hey, I'm getting an error with HTTP Service. Can anyone help?

Hey, devfourm. I hope everyone is having a good day. Now let’s get down to business. I’m making a game to thank star creators and allow people to hang out and thank them as well. I decided to make a webhook that lets me know if anyone in the star program has joined & I was wondering if someone could tell me why my script isn’t working?

Script

local Group = 4199740
local Minimum = 1

game:GetService("Players").PlayerAdded:Connect(function(Player)
	if Player:GetRankInGroup(Group) >= Minimum or Player.UserId == 1384638214 then
		local ReplicatedEvent = game:GetService("ReplicatedStorage").PlayerJoinEvent
		local ThankGUI = script.ThankStarCreator:Clone()
		local Webhook = "https://discord.com/api/webhooks/804193151056609321/k0JydKQFaEzEwzyJBCkwNbHu9z3-BuHgiHa2iFTzdMU-_UkvZpze1EF9NLKG7r64BoPp"
		local HTTPService = game:GetService("HttpService")
		local PlayerUserId = Player.UserId
		local data = {
			['embeds'] = {{
				['title'] = "**STAR CREATOR JOINED**",
				['description'] = Player.Name.." has joined your game!",
				['image'] = game:GetService("Players"):GetUserThumbnailAsync(PlayerUserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420),
				['url'] = "https://www.roblox.com/users/".. PlayerUserId .. "/profile"
			}}
		}
		
		ReplicatedEvent:FireAllClients(Player.Name, Player.UserId)
		ThankGUI.Parent = Player.PlayerGui
		local FinalData = HTTPService:JSONEncode(data)
		HTTPService:PostAsync(Webhook, FinalData)
	end
end)


ERROR

image
I hope you can help. Thanks.

Unrelated:

You might wanna hide your webhook url on the forum because people can copy and paste it and use it for whatever they want

Why is the embeds 2 tables? I’ve only used webhooks once but I think it should be only 1 table

['embeds'] = {
	['title'] = "**STAR CREATOR JOINED**",
	['description'] = Player.Name.." has joined your game!",
	['image'] = game:GetService("Players"):GetUserThumbnailAsync(PlayerUserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420),
	['url'] = "https://www.roblox.com/users/".. PlayerUserId .. "/profile"
}

HTTP 400 means that the request was corrupted or the server couldn’t read it, so that could be the issue

Actually, Discord embeds should be structured as:

['embeds'] = {
	{
		-- data
	}
}

In regards to your question though, the image field should be structured as:

['image'] = {
    ['url'] = 'URL HERE'
}

Make sure to change your webhook url. You shouldn’t be sharing it since anyone can send data to it.

1 Like

I just put in a dummy one for now.