Help Center> Huawei HiLens> SDK Reference> Output> Sending POST Requests
Updated on 2023-06-15 GMT+08:00

Sending POST Requests

This section describes how to send POST requests synchronously. During the request sending process, the threads are blocked until the requests are sent successfully. The TLS1.2 security protocol is supported, and the timeout period is set to 20 seconds.

API Calling

int hilens::POST(const std::string & url, const Json::Value & body, long & httpcode, std::string * response = NULL, POSTHeaders * headers = NULL)

Parameter Description

Table 1 Parameters

Parameter

Description

url

Uniform resource locator

body

JSON object of the message body

httpcode

The return value of the HTTP request. If the Return Value is 200, the request is sent successfully. If the return value is 404, the requested page does not exist.

response

Response. This parameter can be left blank.

headers

Request header. If this parameter is left blank, the header is ignored.

typedef std::vector<std::string> hilens::POSTHeaders

The header of a called POST request can be transferred as a POST parameter (for example, headers.push_back("Content-Type: application/json").

Return Value

Return value of cURL. The value 0 indicates the operation is successful.