http.request
Run an asynchronous web request and receive its result on the game thread.
Syntax
ue.http.request(options: table, callback: function) -> integerThis function is available only in persistent sessions.
Options
| Field | Type | Description |
|---|---|---|
url | string | Required URL. Remote hosts require HTTPS; HTTP is limited to localhost. |
method | string? | HTTP method. Defaults to GET. |
headers | table<string, string>? | Request headers. Managed transport headers cannot be supplied. |
body | string|table? | Binary-safe string body, or a table to JSON encode automatically. |
multipart | MultipartPart[]? | Multipart form fields and binary file data. Mutually exclusive with body. |
timeout_ms | integer? | Per-phase timeout from 1,000–60,000 ms. Defaults to 30,000 ms. |
If body is a table and no content type was supplied, the runtime adds Content-Type: application/json.
A multipart part contains name and exactly one of value or binary-safe data. File parts may also set filename and content_type. The runtime creates the multipart boundary and its Content-Type header; do not supply that header yourself.
Callback
function(response)
-- response.ok: boolean
-- response.status: integer
-- response.headers: table<string, string>
-- response.body: string
-- response.error: string?
endThe callback runs during a later Unreal game-thread tick. Reflected Blueprint calls are safe from inside it. ok is true only for a 2xx status; other responses still include status, headers, and body.
JSON example
ue.http.request({
url = "https://api.example.test/action",
method = "POST",
headers = { Authorization = "Bearer " .. token },
body = { message = "Hello" }
}, function(response)
if not response.ok then
ue.log.error(response.error, response.status)
return
end
local result = assert(ue.json.decode(response.body))
print(result.message)
end)Multipart example
ue.http.request({
url = "https://api.example.test/transcribe",
method = "POST",
headers = { Authorization = "Bearer " .. token },
multipart = {
{ name = "language", value = "en" },
{
name = "file",
filename = "voice.wav",
content_type = "audio/wav",
data = wav_bytes
}
}
}, callback)Notes
- Request and response bodies are limited to 16 MiB; multipart supports 1–64 parts.
- Redirects are disabled so credentials cannot silently follow a redirect.
- Binary bytes are preserved.
- Transport and URL errors are reported asynchronously through the callback.