InvokeServer() returning HTTP 400

Hello,

I am trying to use remote functions, and :InvokeServer()

Simple explanation, Roblox is returning HTTP 400 (bad request)

Any reasons why it does this?

1 Like

Would it be possible for you to share the code so we can have some context with this use.

Yes one second.

		for gg, ba in pairs(Main:GetDescendants()) do
			if ba:IsA("TextLabel") or ba:IsA("TextButton") then

				local language = string.split(localid, "-")[1]
				if ba.Text ~= "" then
					local trans = ba.Text


					trans  = game.ReplicatedStorage.tsHubEvents.languageInvokeEvent:InvokeServer({ba.Text, string.lower(language)})



					if trans ~= nil then
						ba.Text = trans
					end
				end

			end
		end

You are using a local script correct?

Yes -----------------------------------

string.split() returns an array, so you can’t perform string.lower() on it.

thats why after string.split i added [1] (cause localid is the robloxlocaleid and i just want the language so i take something like “en-us” and take [1] “en” out of it

That still should not cause that return issue. What you are saying would affect the code before the invokeserver is fired not after in the return.

Could we take a look at the backend code that is handling this remote function?

2 Likes
local function translate(plr, tbl)

	local language = tbl[2]
	local text = tbl[1]
    if settings.Language == "Auto" then

    
		if tableOfLanguages[language] ~= nil then
			print(langMod.Translate(text, tableOfLanguages[language], "English", nil, "Google") )
		local newtext = text
		local success,err = pcall(function()
			newtext = langMod.Translate(text, tableOfLanguages[language], "English", nil, "Google") 
		end)
			if success then
				if newtext ~= "Dom" then
					return newtext
				else
					return "strona główna"
				end
		end

		end
	else
		local newtext = text
		local success,err = pcall(function()
			newtext = langMod.Translate(text, settings.Language, "English", nil, "Google") 
		end)
		if success then
			if newtext ~= "Dom" then
				return newtext
			else
				return "strona główna"
			end
		end
	end
end

game.ReplicatedStorage.tsHubEvents.languageInvokeEvent.OnServerInvoke = translate

langMod is a translate module
tableOfLanguages is just a thing that lists stuff like [“en”] = "English

HTTP 400 usually means the 3rd-party API is rejecting the content sent via HTTPService, usually due to the data being invalid. Make sure you are using the module correctly, as I am unfamiliar with the module.

Thank you!!! I think its because im requiring the module wrong…