game:HttpPost

Sends data with HTTP POST.

Syntax

Signature
game:HttpPost(Url: string, Body: string, ContentType: string?) -> string

Aliases

  • http.httppost
  • game:HttpPostAsync
  • httppost

Parameters

ParameterTypeDescription
UrlstringHTTP or HTTPS URL.
BodystringRequest body, up to 16 MiB.
ContentTypestring?Content-Type header. Defaults to text/plain.

Returns

TypeDescription
stringThe response body.

Notes

httppost and game:HttpPost use the same implementation. ContentType defaults to text/plain. A non-2xx status or transport failure raises an error.

Example

Luau
local Body = json.encode({message = "Hello"})
local Response = httppost(
    "https://httpbin.org/post",
    Body,
    "application/json"
)

local Data = json.decode(Response)
print(Data.json.message)