So I’m trying to send a http PUT, using the httpService:RequestAsync() function. Although it tells me that I need a content length. When I include this in the header (called [“Content-Length”] = 0) it tells me that I’m not allowed to use that header.
Is there any way to include the Content-Length? I’ve tried the same request from this website which worked fine.
If developers read the documentation before replying, there’d be less speculation about what’s going on here. See RequestAsync. Content-Length is determined by the Body and thus cannot be defined in your Headers. A very different error would be produced if the endpoint in question rejected Roblox’s User-Agent from making requests to its API.
function API.HttpRequest(Url, Method, Headers, Body)
if Method == "POST" and not Body then Body = jsonEncode({ }) end
--print(Url, Method, Body)
return game:GetService("HttpService"):RequestAsync({
Url = Url,
Method = Method or "GET",
Headers = Headers,
Body = Body,
})
end
function API.Request(Path, Method, Headers, Body)
--print("!"..#Body, Path,Method,Headers,Body)
--Headers["Content-length"] = #Body
local Data = API.HttpRequest(API.Config.Host .. Path, Method, Headers or { --.. ":" .. API.Config.Port
Authentication = API.Config.Authentication,
}, Body
).Body
print(Data)
return jsonDecode(Data)
end
The request needs a Content-Length in the Headers, not the body, usually it’s done automatically by Roblox, but for some reason it doesn’t accept the request, I already tried adding it to the body, obviously it does nothing