유틸리티

HttpPost

POST 요청을 보내고 응답 본문을 반환합니다.

문법

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

인수

이름타입설명
contextany메서드 스타일 도우미를 호출할 때 제공되는 자체 또는 컨텍스트 인수입니다.
urlstring연결할 HTTP 또는 WebSocket URL입니다.
body?stringHTTP 요청과 함께 전송된 요청 본문입니다.
contentTypeOrCompatibility?string | number | boolean레거시 HttpPost 서명에 대한 콘텐츠 유형 또는 호환성 플래그입니다.
headersOrContentType?table | string호출 스타일에 따라 헤더 테이블 또는 콘텐츠 유형 값.
headers?table요청과 함께 전송된 HTTP 헤더입니다.

반환값

이름타입설명
bodystringHTTP 응답 본문.

설명

POST 요청을 보내고 응답 본문을 반환합니다.

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

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

예제

자리 표시자 값을 사용하는 예제 호출입니다.

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