HTTP 400 (Bad Request) after posting to a discord webhook

  1. What do you want to achieve? Make a report system for my game, which sends the player’s reports to a discord webhook.

  2. What is the issue? After submitting the report, it won’t post it to a discord webhook, instead i get a HTTP 400 (Bad Request) error.

  3. What solutions have you tried so far? Posting without thumbnail, and without requesting it. I’ve also tried looking for solutions on roblox devforum, but I couldn’t find any solution that fits my problem.

This is my code:

local http = game:GetService("HttpService")
local link = ""

local debounce = false
game.ReplicatedStorage.BugReport.OnServerEvent:Connect(function(player, report)
	if debounce then return end --Cooldown so people can't spam messages
	debounce = true
	
	local s, PictureUrl = pcall(function()
		return http:JSONDecode(http:GetAsync("https://thumbnails.roproxy.com/v1/users/avatar-headshot?userIds="..player.UserId.."&size=150x150&format=Png")) --use api and proxy to get LINK, you can change size
	end)
	if s and PictureUrl then
		PictureUrl=PictureUrl.data[1].imageUrl
	else
		PictureUrl="https://t3.rbxcdn.com/9fc30fe577bf95e045c9a3d4abaca05d" --link if can't get player headshot (default img)
	end
	
	local data = {
		["content"] = "New report on FAIR Doomspire Brickbattle",
		["username"] = player.Name,
		["thumbnail"] = {
			["url"] = PictureUrl
		},
		["embeds"] = {
			{
				["title"] = "New report on FAIR Doomspire Brickbattle",
				["description"] = "From: "..player.Name,
				["color"] = tonumber(0xffffff),
				["fields"] = {
					{
						["name"] = "Report",
						value = report
					},
					{
						["name"] = "By",
						["value"] = player.Name,
						["inline"] = true
					},
					{
						["name"] = "UserID",
						["value"] = player.UserId,
						["inline"] = true
					},
					{
						["name"] = "Player DisplayName",
						["value"] = player.DisplayName,
						["inline"] = true
					},
					{
						["name"] = "Player Team",
						["value"] = player.Team,
					}
				}
			}
		}
	}
	data = http:JSONEncode(data)
	
	http:PostAsync(link, data)
	
	wait(10) --Cooldown time
	debounce = false
end)
1 Like

you cant use discord webhooks as they have been blocked

use this

also don’t use wait(), use task.wait() instead, it’s much better

1 Like

It still returns bad request (400)

Is access to API services and HTTP service granted in your game’s settings?

Yes, I have granted access to API services and HTTP service.

1 Like