I’m trying to send a GET request to a specific website, which told me how to do it. Now this is my script:
local kkey = "SECRET-KEY" -- The original is hidden
local response = HttpService:RequestAsync(
{
Url = "SPECIFIC-WEBSITE",
Method = "GET",
Headers = {
["Accept"] = "application/json",
["Content-Type"] = "application/json",
["Authorization"] = "Bearer " .. kkey
},
}
)
if response.Success then
print("Done")
else
print("The request failed:", response.StatusCode, response.StatusMessage)
end
it all works, but when I try to run it, it gives me the following error:
“The request failed: 411 Length Required”
Does anyone know how I can fix this?
1 Like
The website will not accept the request without a content-length header.
Read More
Okay so I added this
Headers = {
["Accept"] = "application/json",
["Content-Type"] = "application/json",
["Content-Length"] = 0,
["Authorization"] = "Bearer " .. kkey
},
and now it tells me this:
This might be an issue with how Roblox manages and sends HTTP requests, I’d try contacting Roblox support.
EDIT: This may also be the webserver/website issue, possibly to protect against DDOS and DOS attacks
I think its a roblox issue. I saw someone do the same thing with a synapse function instead of :RequestAsync, which included the same information, and it worked all fine for them. I’ll try to contact roblox support for this, but I don’t think anything is gonna change.
Body = HttpService:JSONEncode({
["Content-Length"] = 0
})
Put this in the request, this should fix it
Aegians
(Aegian)
March 18, 2021, 5:56pm
#7
That’s just his own answer from his other post.
yea i just put this here incase anyone else comes across this issue as this is the only post that is called “411 Length Required” on the forum
thanks how did you find that out
I found it from another post, ill try to PM you when i find it.
that’s literally what I put here lol
i didn’t even realize it was your post xd, anyways, post a solution to this topic so it has an answer as this is the only topic with the name “411 Length Required” on the devforum
Found out the solution from my following post:
FIXED:
For anyone else struggling with this, add “Content-length” to the body, like so:
local post = HttpService:RequestAsync( {
Method = "PUT",
Url = "URL",
Headers = {
["Content-Type"] = "application/json",
},
Body = HttpService:JSONEncode({
["Content-Length"] = 0
})
})