HTTP errors, anyone know a fix?

ok, I know I made a post similar to this last night, but I am back with a new error.

so I am trying to send to discord, using this script:

local http = game:GetService("HttpService")

local Data = {

["content"] = "test test"

}

while true do

Data = http:JSONEncode(Data)

http:PostAsync("https://discord.com/api/XXXX", Data)

wait(30)

end

but when I run it, it sends successfully once, and then on the second send it returns “HTTP 400 (Bad Request)”, Im confused as to why it works without a error the first time, and then fails the second. does anyone know what the error is/why it only returns the second time?

You are trying to encode a table thats already encoded. In the while true do loop you need to change the variable “Data” to something like “EncodedData” or make it local because you already have a variable named Data.

oh ok, thanks! I will try this and make as a solution if it fixes it!

1 Like

thank you, it worked! if I could ask what does encoding do, I still am trying to learn more about webhooks/APIs.

Encoding takes an input value and puts it into a specific format. Networking typically uses the JSON format specifically. So JSON encoding in this case takes the table (Data) you send and puts it into JSON(JavaScript Object Notation) format so that the discord server can read it. If you were to send the regular roblox table as the data the server would not be able to read and understand it.

ok, sorry for pestering you with so many questions, but last night I asked on a different thread why when I tried to use a proxy to access the roblox API it gave me a 429 saying I had sent to many requests, even if I had just sent one. others said that the API was down, but it has been 16 hours and it is still not working, do you know if it is still down or should I check over my script?

I’ve had this happen before. It is either because roblox doesn’t like you using a proxy and will give you a 429 error code no matter really how long you wait, or if you’re using a public proxy other people are probably using it for the same thing(to send requests to the roblox API endpoints)

ok, I will try to create a private one, thanks for the help!

1 Like

I wouldn’t use roblox to send webhooks. There are a lot of good posts about using node servers and what not.