Skip to content

CALL_REST_RAW

Jurek Muszyński edited this page Sep 11, 2018 · 2 revisions

bool CALL_REST_RAW(void *req, void *res, const char *method, const char *url)

Description

Makes HTTP request. req and res are char* pointers. CALL_REST_RAW can block for up to RESTTimeout milliseconds. If not set, CALL_REST_DEFAULT_TIMEOUT is used, which is currently 1000 ms.

For more information see RESTful calls from Silgy.

Returns

true if the full response content was read successfully, otherwise false. res will contain a NULL-terminated string with response body.

Example

REST_HEADERS_RESET;

REST_HEADER_SET("apiConsumerId", "123456789");
REST_HEADER_SET("Authorization", "Bearer v2-6998a852-1521-4745-a1f3-e55341092e9f");

if ( CALL_REST_RAW(req_str, res_str, "GET", "example.com:8888/api/v1.0/accounts/v1.0/getAccount") )
{
    OUT("<p>Got response</p>");
    OUT("<p style=\"font-family:monospace; font-size:10pt; white-space:pre;\">%s</p>", res_str);
}
else
{
    OUT("<p>Something went wrong</p>");
}
Clone this wiki locally