Discord Webhook Invoking HTTP Error

I am trying to design a user feedback system in which users can type in a text box and they could submit their feedback directly to my discord webhook. When I tried it for myself, I keep on getting an HTTP 400 error. CONTEXT: There is a remote event in ReplicatedStorage and a text box and text button in startergui, a localscript in startergui and a script in serverscriptservice. Here is the code:

LocalScript:

FeedbackGUI.Frame.submit.Activated:Connect(function()
	local text = PlayerGui.ReportGui.Frame.TextBox.Text
	SubmitReport:FireServer(text)
end)

Script:

local HTTPService = game:GetService("HttpService")

local feedback = game.ReplicatedStorage.SubmitReport.OnServerEvent:Connect(function(player, msg)
	local name = tostring(player.Name)
    tostring(msg)
	return name .. " said " .. msg
end)

local Data = {
	["content"] = feedback
}

Data = HTTPService:JSONEncode(Data)

HTTPService:PostAsync("URL", Data)

Output:

13:04:48.796 - HTTP 400 (Bad Request)

The discord URL works and the remote event also works. Just the last step doesn’t work, i.e. somewhere within the server-script.

That is not how events work, and you’re pretty much doing it all wrong. Try this:

game.ReplicatedStorage.SubmitReport.OnServerEvent:Connect(function(player, msg)
	local name = player.Name
	local feedback = name .. " said " .. msg
    local Data = {
        ["content"] = feedback;
    }

    Data = HTTPService:JSONEncode(Data)
    HTTPService:PostAsync("URL", Data)
end)
1 Like

I would also suggest you to make some kind of filter for your Feedback system. This would make filtering goods from the bads easier.

Some ideas:
Save time feedback is being sent (os.time()), and compare it with previous one, if the time difference is less than 30 minutes, you really should not pass it.
Minimum character lenght so people cant just write “Cool” and hit send.