Hello guys. i made a script that sends a HttpGet but for some reason it keeps saying HTTP 400. this is my code. is this because of the magic characters?
local HttpService = game:GetService("HttpService")
local TextService = game:GetService("TextService")
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("WaterBotMessage")
Remote.OnServerEvent:Connect(function(Player,Message)
if type(Message) == "string" and #Message <= (1997-(#Player.Name-#Player.DisplayName)) then
local FilteredString = nil
local Success,Error = pcall(function()
local FilteredInstance = TextService:FilterStringAsync(Message,Player.UserId)
FilteredString = FilteredInstance:GetNonChatStringForUserAsync(Player.UserId):gsub("#","%%")
end)
if Success then
local PlayerInformation = Player.Name.." ("..Player.DisplayName..")"
local JSONEncoded = "http://ihidtheapilink?JSONEncoded={\"embeds\":[{\"title\":"..FilteredString..",\"description\":"..PlayerInformation.."}]}"
local POSTSuccess,POSTError = pcall(function()
print(JSONEncoded)
HttpService:GetAsync(JSONEncoded)
end)
if POSTError then
print(POSTError)
end
end
end
end)
In other words, the request you sent to the API endpoint is invalid in someway. It could be wrongly formatted request message framing, or invalid request syntax. Check that youβre sending the request path parameters correctly.
then i cant set the variable on the other side, the ?JSONEncoded variable was to set the JSONEncoded on the api to a JSON then send it to a discord webhook.
If you made this API endpoint, I suggest making the request parameters a part of the request body instead of using query parameters. It would make things much easier.