request
Sends an HTTP or HTTPS request and returns the complete response.
Syntax
request(options: RequestOptions) -> Response
Also available as
httprequesthttp.requesthttp_request
Parameters
| Parameter | Type | Description |
|---|---|---|
options | table | Url is required. Method, Headers, Cookies and Body are optional. |
Returns
| Type | Description |
|---|---|
Response | Status, headers, cookies and body returned by the server. |
Description
Options include Url, Method, Headers, Cookies and Body. Method defaults to GET. Headers and Cookies are string-keyed tables; Body is a byte string. The call yields while networking is in progress.
On third-party hosts, the default User-Agent is Apex/<application version>. When a joined server JobId is known, Roblox-Game-Id contains that JobId and Roblox-Session-Id contains a JSON object with GameId set to the same value. These optional headers are omitted when no valid JobId is known. Scripts can override the User-Agent and session headers.
Apex supplies Apex-Fingerprint and Apex-User-Identifier according to the HTTP identity policy. Values passed in Headers for those names are ignored, including case variants.
The response contains Success, StatusCode, StatusMessage, Headers, Cookies and Body. An HTTP error such as 404 is still a response: inspect Success and StatusCode before interpreting Body. Transport, URL and configuration failures can raise errors. HTTPS requests validate the remote certificate. Use game.HttpGet when only a successful response body is needed.
Example
local ok, response = pcall(request, {
Url = "https://example.com/",
Method = "GET",
Headers = { Accept = "text/html" },
})
if ok then
print(response.StatusCode, response.Success, #response.Body)
else
warn(response)
end
Notes
- Body is not automatically decoded as JSON. Use HttpService:JSONDecode when appropriate.
These are Game executor contracts. Check build requirements and session lifetimes before using them.
