http.request

Run an asynchronous web request and receive its result on the game thread.

Syntax

ue.http.request(options: table, callback: function) -> integer

This function is available only in persistent sessions.

Options

FieldTypeDescription
urlstringRequired URL. Remote hosts require HTTPS; HTTP is limited to localhost.
methodstring?HTTP method. Defaults to GET.
headerstable<string, string>?Request headers. Managed transport headers cannot be supplied.
bodystring|table?Binary-safe string body, or a table to JSON encode automatically.
multipartMultipartPart[]?Multipart form fields and binary file data. Mutually exclusive with body.
timeout_msinteger?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?
end

The 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.

On this page