HTTP 400 (Bad Request) error

I get HTTP 400 (Bad Request) error with this script:

local url = "webhook_url"
local http = game:GetService('HttpService')
local MarketplaceService = game:GetService("MarketplaceService")

local event = game.ReplicatedStorage.logEvent

game.Players.PlayerAdded:connect(function(plr)
	plr.Chatted:connect(function(msg)
		local players = game:GetService("Players")
		
		local data = {
			['username'] = plr.Name.." | "..MarketplaceService:GetProductInfo(game.PlaceId).Name,
			["avatar_url"] = game:GetService("Players"):GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150),
			['content'] = msg
		}
		local newdata = http:JSONEncode(data)
		http:PostAsync(url,newdata)
	end)
end)

Any solutions?
(It’s connected to a discord webhook)

Did you activate the HTTP thing in game settings?

1 Like

I think its problem with formating message. Check this link
https://embed.discord.website/

1 Like

Discord have a limit for webhooks.
30 messages for every minute maybe because that is not working.

1 Like

I was testing it alone and it was showing still error .I think it just wrong format of message

1 Like

There’s gotta be something wrong with the formatting, check the formatting and make sure it’s right.

1 Like

Alright, I checked everything and it seems to work without the avatar_url variable. Any ideas on how to fix that?

The issue is that GetUserThumbnailAsync returns a rbxthumb:// content type, which is only usable in roblox. The solution would be to use the https:// link that roblox uses to fetch user thumbnails

string.format("https://www.roblox.com/headshot-thumbnail/image?userId=%s&width=150&height=150&format=png", plr.UserId)
1 Like