game:HttpPost
Sends data with HTTP POST.
Syntax
Signature
game:HttpPost(Url: string, Body: string, ContentType: string?) -> stringAliases
http.httppostgame:HttpPostAsynchttppost
Parameters
| Parameter | Type | Description |
|---|---|---|
Url | string | HTTP or HTTPS URL. |
Body | string | Request body, up to 16 MiB. |
ContentType | string? | Content-Type header. Defaults to text/plain. |
Returns
| Type | Description |
|---|---|
string | The 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)