ไวยากรณ์
HttpPost(context: DataModel, url: string, body?: string, contentTypeOrCompatibility?: string | number | boolean, headersOrContentType?: table | string, headers?: table): stringArguments
| ชื่อ | ชนิด | คำอธิบาย |
|---|---|---|
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. |
Returns
| ชื่อ | ชนิด | คำอธิบาย |
|---|---|---|
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.
เรียกด้วย parameter 6 ค่า: context, url, body, contentTypeOrCompatibility, headersOrContentType, headers ตาราง arguments อธิบายค่าที่จำเป็นและค่าที่ปรับพฤติกรรม
ส่งคืน body (string) ใช้ตาราง returns เพื่อแยกค่าที่สำเร็จ ผลลัพธ์ nil และ error ที่จัดการต่อได้
ตัวอย่าง
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)