Miscellaneous

HttpPost

Performs a POST request for game:HttpPost(...) or game:HttpPostAsync(...) and returns the response body string or a request error string.

문법

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

인수

이름타입설명
contextDataModelMethod-call self value. Use game:HttpPost(...) or game:HttpPostAsync(...).
urlstringURL string to request.
body?stringOptional request body. Defaults to an empty string.
contentTypeOrCompatibility?string | number | booleanNormally the content type string. A number uses legacy timeout mode, and a boolean uses legacy compression mode.
headersOrContentType?table | stringOptional headers table in the normal call shape, or optional content type string in legacy mode.
headers?tableOptional headers table used only in legacy mode. Keys and values must be strings without CR or LF.

반환값

이름타입설명
bodystringResponse body string or request error string.

설명

Performs a POST request for game:HttpPost(...) or game:HttpPostAsync(...) and returns the response body string or a request error string. The URL must pass Real's URL restrictions.

6개 파라미터로 호출합니다: context, url, body, contentTypeOrCompatibility, headersOrContentType, headers. 인수 표는 필수 값과 동작을 조정하는 값을 설명합니다.

body (string)을 반환합니다. 반환 표를 사용해 성공 값, nil 결과, 복구 가능한 오류를 구분하세요.

예제

Run a DataModel-style POST request and return the response body string.

local body = game:HttpPost(
    "https://example.com",
    '{"hello":"world"}',
    "application/json",
    { ["X-Example"] = "Real" }
)

print(body)