Skip to main content

HTTP

Deprecated version

This document refers to a deprecated version of the RQL programming language.

Please go here for documentation related to the latest supported version.

Makes an HTTP request.

Syntax
HTTP(url: string,
method: string := "get",
encoding: string := "utf-8",
body_string: string nullable := null,
body_binary: binary nullable := null,
token: string nullable := null,
client_id: string nullable := null,
client_secret: string nullable := null,
token_url: string nullable := null,
renew_token_use_basic_auth: bool nullable := null,
username: string nullable := null,
password: string nullable := null,
args: collection(tuple(string, string)) := [],
headers: collection(tuple(string, string)) := [],
expected_status: collection(int) nullable := [200, 201, 202, 203, 204, 205, 206])

The return type is record(status: int, data: string, headers: collection(tuple(string, string))), with the HTTP status, data decoded as a string and the returned headers.

The expected_status argument specifies a list of valid/expected status for this request, the query will fail if the returned status is not included there. To make a HTTP call without checks set this argument to null.

The arguments body_string and body_binary specify the body to send in request and cannot be used together. If body_string and body_binary are defined in the same call this will create an error.

Example
request := HTTP("http://www.server.users",
method := "POST",
args := [("name", "john")],
headers := [("Authorization", "Bearer token"), ("Accept", "application/json")]
);
select * from parse_json[collection(record(name: string, age: int))](request.data)