HTTP 400 (Bad Request) What are reasons for this error to be thrown? Discord Webhook.
Asked by
4 years ago Edited 4 years ago
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:
01 | local function REPORT_TO_DISCORD(player,target,reason) |
02 | local result,err = pcall ( function () |
03 | local url = "REDACTED" |
04 | local report_base = [[ |
11 | embed.timestamp = getCurrentTime() |
16 | player:GetRoleInGroup( 3587367 ) or "N/A" , |
19 | game:GetService( "MarketplaceService" ):GetProductInfo(game.PlaceId).Name, |
28 | url = game.Players:GetUserThumbnailAsync( |
30 | Enum.ThumbnailType.AvatarBust, |
31 | Enum.ThumbnailSize.Size 420 x 420 |
37 | icon_url = game.Players:GetUserThumbnailAsync( |
39 | Enum.ThumbnailType.HeadShot, |
40 | Enum.ThumbnailSize.Size 420 x 420 |
44 | local HookData = { username = player.Name, avatar_url = game.Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size 420 x 420 ), embeds = { embed } } |
45 | HookData = http:JSONEncode(HookData) |
47 | http:PostAsync(url, HookData) |
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.