Utilities

HttpPost

Sends a POST request and returns the response body.

Syntax

HttpPost(context: any, url: string, body?: string, contentTypeOrCompatibility?: string | number | boolean, headersOrContentType?: table | string, headers?: table): string

Arguments

NameTypeDescription
contextanySelf or context argument supplied when calling method-style helpers.
urlstringHTTP or WebSocket URL to connect to.
body?stringRequest body sent with the HTTP request.
contentTypeOrCompatibility?string | number | booleanContent type or compatibility flag for legacy HttpPost signatures.
headersOrContentType?table | stringHeaders table or content type value, depending on the calling style.
headers?tableHTTP headers sent with the request.

Returns

NameTypeDescription
bodystringHTTP response body.

Description

Sends a POST request and returns the response body.

Call it with 6 parameter(s): context, url, body, contentTypeOrCompatibility, headersOrContentType, headers. The argument table explains which values are required and which ones only refine the behavior.

It returns body (string). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = HttpPost(nil, "example", "example", "example", "example", {})
print(result)