InvokeServer returns "Bad Gateway"

Hi! My script is supposed to send a quiz thats filled out locally for the server script to send a webhook with it. Think of it as a feedback form. Anyway, it doesn’t work and keeps returning HTTP 502 (Bad Gateway).

Relevant part of the localscript:

local success = "no"
		success = game.ReplicatedStorage.FilteringFunction:InvokeServer(msg1, msg2, msg3, msg4, msg5, host)
		if success ~= "no" then
			feedbackMain.SendButton.Text = success
			feedbackMain:TweenPosition(UDim2.new(0.25, 0,-2, 0),"Out","Quint",0.3,true)
			db = false
		else
			warn(success)
			feedbackMain.SendButton.Text = "Error ("..success.."). Trying again!"
			task.wait(2)
		end

Relevant part of the serverscript:

function filteringFunction.OnServerInvoke(player, msg1, msg2, msg3, msg4, msg5, host)
-- webhook data
	local newdata = HTTP:JSONEncode(data)

	HTTP:PostAsync(webhook, newdata)
	return "Quiz submitted."
end

I’ve tried pcall and some other tweaks (even consulting Mr. AI themselves) and I just keep getting the same error. The webhook is using a reliable (tested) proxy. Plz help!

Side note: The error points to this line success = game.ReplicatedStorage.FilteringFunction:InvokeServer(msg1, msg2, msg3, msg4, msg5, host)

1 Like

That a common sense that Http request may error
Also make sure to inline function/instance referance:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local bindable = ReplicatedStorage.FilteringFunction

Pro tip:
Use this plugin for service auto completion: https://create.roblox.com/store/asset/11380642657


local post = HTTP.PostAsync
function filteringFunction.OnServerInvoke(player, msg1, msg2, msg3, msg4, msg5, host):(boolean,any)
-- webhook data
	local newdata = HTTP:JSONEncode(data)

	return pcall(post,HTTP,webhook,newdata)
end

Does the error occur on the invokation of the remote event or in the connection of the remote event?

If it is the remote event, how much data are you trying to send? I can’t imagine this is an issue but its good to know.

You’re doing HTTP:JSONEncode(data), but I see no data variable, so what are you trying to encode?