I’m currently toying around and learning httpservice, for some reason I keep bumping into HTTP 400(bad request), what’s wrong about this script
local http = game:GetService("HttpService")
local message = {
["content"] = nil
}
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
-- print(plr.Name, msg)
message = http:JSONEncode(msg)
http:PostAsync("<MyWebhookLink>", message)
end)
end)
Thanks for reading!
njesk12
(njesk12)
April 26, 2021, 8:32am
#2
The 400 bad request error code is when you’re not sending the parameters correctly to the API. Refer to the API that you are using as well to ensure that you have everything in the header you need to process the data.
Also ensure you have HttpService Enabled in your game.
1 Like
Yep, I noticed, changed it like this
local http = game:GetService("HttpService")
local message = {
["content"] = nil
}
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
-- print(plr.Name, msg)
msg = {
["content"] = msg
}
message = http:JSONEncode(msg)
http:PostAsync("link", message)
end)
end)
1 Like
What website are you using for it?