Alright, so here is what I know for sure:
• I have the correct URL
• All of the arguments in the function are correct.
• I am not new to the Roblox development world, and have done things similar to this before.
Some basic information: This is a request to go directly from Roblox to a Discord webhook.
This is a function which I am trying to call every time a player submits a report in my game. Regardless of how much time I give in-between calls, this function throws the error "HTTP 400 (Bad Request)".
Here is the function:
local function REPORT_TO_DISCORD(player,target,reason) local result,err = pcall(function() local url = "REDACTED" local report_base = [[ **Username:** [%s](https://www.roblox.com/users/%s/profile) (%s) **Reported:** %s **Reason:** %s **Game:** [%s](https://www.roblox.com/games/%s/Game) ]] local embed = {} embed.timestamp = getCurrentTime() embed.description = { report_base:format( player.Name or "N/A", player.UserId, player:GetRoleInGroup(3587367) or "N/A", target or "N/A", reason or "N/A", game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Name, game.PlaceId ) } embed.footer = { icon_url = "", text = "Report Log" } embed.thumbnail = { url = game.Players:GetUserThumbnailAsync( player.UserId, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size420x420 ) } embed.author = { name = player.Name, url = "https://www.roblox.com/users/" .. player.UserId .. "/profile", icon_url = game.Players:GetUserThumbnailAsync( player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420 ) } local HookData = {username = player.Name, avatar_url = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420), embeds = {embed}} HookData = http:JSONEncode(HookData) http:PostAsync(url, HookData) end) if not result then warn(err) end end
EDIT: Redacted the URL, and deleted the webhook.
I know some of the possible reasons for "HTTP 400 (Bad Request)" being thrown, however, there is always something new to learn.
Hopefully an answer to this query can help me and many others,
EDIT 2: I found another way of accomplishing this, however, if someone can provide an answer that would still help others.
I would say that the reason for this is because the information being transmitted to Discord is invalid, or the formatting is invalid.
I would double check the formatting to ensure that everything is as it should be.