HttpService Error 404 (Forbidden) When PostingAsync

Hey there,

I’ve recently added a report feature to my game, and for some reason the script only works in studio and comes up with an error when in a real server.

Here’s some info below:

Error Message:

image

Server-Side Script:


local function filter(text,player) 
	local msg = chat:FilterStringAsync(text, player, player)
	return msg;
end

Events.Report.OnServerEvent:Connect(function(player,reason,user)
	local formatted = httpsService:JSONEncode({
		content = "Reporting: "..filter(user, player).."\nReason: "..filter(reason, player);
		username = player.Name..":"..player.UserId;
		avatar_url = ('https://www.roblox.com/headshot-thumbnail/image?userId=' .. player.UserId .. '&width=420&height=420&format=png')
	})
	
	httpsService:PostAsync(webook, formatted)
end)

Client-Side Script:

Report.MouseButton1Click:Connect(function()
	if debounce == false then
		debounce = true
		
		if Reason.Text ~= "" then
			Events.Report:FireServer(Reason.Text, Username.Text)
		end
		
		Reason.Text = "Your have successfully reported "..Username.Text.."!"
		wait(1)
		Reason.Text = "Enter your reasoning here..."
		Username.Text = "Username"
		debounce = false
	end
end)

Not sure why it only works in studio, so if you know, please do help me out! Thanks! :slight_smile:

2 Likes

According to this post, setting the game access to public may resolve the issue

Yeah, I saw that. I made the game public but the same error occurs.

May not have anything to do with it, but you misspelt webhook (its a variable name, so if you did it wrong twice, then it shouldn’t matter)
Also, what is the URL/Value of webook

The variables are the same name, so it shouldn’t create any errors. The value of “webook” is just a discord webhook so it shouldn’t be posting any errors, I left that part out of the script for safety reasons.

Full script: (Stared the last parts of the URL)

local webook = "https://discord.com/api/webhooks/926186406802501685/yeZojuEo9A9br4dS7Wy-1or4N9mqdhF5jXpFLut5xJ**********************************"

local httpsService = game:GetService("HttpService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local chat = game:GetService("Chat")

local Events = ReplicatedStorage:WaitForChild("Events")

local function filter(text,player) 
	local msg = chat:FilterStringAsync(text, player, player)
	return msg;
end

Events.Report.OnServerEvent:Connect(function(player,reason,user)
	local formatted = httpsService:JSONEncode({
		content = "Reporting: "..filter(user, player).."\nReason: "..filter(reason, player);
		username = player.Name..":"..player.UserId;
		avatar_url = ('https://www.roblox.com/headshot-thumbnail/image?userId=' .. player.UserId .. '&width=420&height=420&format=png')
	})
	
	httpsService:PostAsync(webook, formatted)
end)

Is http service enabled or not

Yep, as well as the game being public, so I’m not sure why there’s an error.

I mean if it works normally ingame it could just be a studio bug.

It doesn’t work in-game, but works in studio so I’m confused on why.

Ah use a proxy because discord blocked all connections.

I can list some proxies for you.

Use a proxy, Discord has blocked Roblox UserAgent and probably wont restore it. Here is a good one: Discord Webhook Proxy

1 Like

You are not formatting the table correctly it should be:

local formatted = httpsService:JSONEncode({
		["content"] = "Reporting: "..filter(user, player).."\nReason: "..filter(reason, player),
		["username"] = player.Name..":"..player.UserId,
		["avatar_url"] = ('https://www.roblox.com/headshot-thumbnail/image?userId=' .. player.UserId .. '&width=420&height=420&format=png')
	})

Make sure that the Webhook URL is correct

hooks.hyra.io is a proxy I can list a webhook example.

https://hooks.hyra.io/api/webhooks/914962644119748608/BD3ORjmhz6gNj5W-cUAMGM_tSxhfyC4hWWejK8IY61VsFtjhc5L***************************

Proxy isn’t needed because requests to discord aren’t blocked as for roblox.com

They are. Whole Roblox UserAgent is blocked.

Discord blocked all connections to roblox I mean so you have to use a proxy.

What?! Since when? I used it recently and it worked fine

1 Like

Well some people started spamming it and just abusing it so they blocked all connections. It also depends on what your using it for.

2 Likes

Now discord has blocked all connection of robloxAgent.

3 Likes