構文
HttpPost(context: DataModel, url: string, body?: string, contentTypeOrCompatibility?: string | number | boolean, headersOrContentType?: table | string, headers?: table): string引数
| 名前 | 型 | 説明 |
|---|---|---|
context | DataModel | Method-call self value. Use game:HttpPost(...) or game:HttpPostAsync(...). |
url | string | URL string to request. |
body? | string | Optional request body. Defaults to an empty string. |
contentTypeOrCompatibility? | string | number | boolean | Normally the content type string. A number uses legacy timeout mode, and a boolean uses legacy compression mode. |
headersOrContentType? | table | string | Optional headers table in the normal call shape, or optional content type string in legacy mode. |
headers? | table | Optional headers table used only in legacy mode. Keys and values must be strings without CR or LF. |
戻り値
| 名前 | 型 | 説明 |
|---|---|---|
body | string | Response 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)