HTTP_CONNECTION
A struct type with the base information of the requests to one server.
Declare it with VARIABLE api STRUCT c0de_net/http/HTTP_CONNECTION and set its elements with ASSIGN. Only server is needed, all other elements start with defaults that fit most servers.
use_sslBOOLEAN: true for https, false for http (default false)serverSTRING: the server name or IP address, must not be emptyportINTEGER: 1 to 65535, or 0 for 80 or 443 (default 0)base_endpointSTRING: a path in front of every endpoint, like /api/v2userSTRING: the user name for basic authentication, empty for nonepasswordSTRING: the password for basic authenticationskip_ssl_validationBOOLEAN: true to accept any certificate, e.g. a self-signed one (default false)proxySTRING: an HTTP proxy like http://proxy:3128, empty for noneheadersHASH STRING: headers sent with every request, like Content-TypetimeoutINTEGER: seconds a request may take, 1 to 300, or 0 for 60 (default 0)
The URL of a request is the protocol, the server, the port, the base endpoint and the endpoint, like https://api.example.com/v2/users/7. The endpoint is used as it is, with its query, like /search?q=stone.
An Authorization header in headers replaces the basic authentication. The headers Host, Content-Length, Connection, Expect and Upgrade can't be set.
The password is stored in the program like any other value, and everybody who can read the sheet can read it. Pass secrets in as a parameter, from a constant item in the trigger block.
Example
PROGRAM connect
NOOP
INCLUDE c0de_net/http
NOOP
FUNCTION run
PARAMETER token STRING
BEGIN
VARIABLE api STRUCT c0de_net/http/HTTP_CONNECTION
ASSIGN api.use_ssl TRUE ;
ASSIGN api.server "api.example.com" ;
ASSIGN api.base_endpoint "/v2" ;
ASSIGN api.headers["Authorization"] "Bearer " ⊕ token ;
ASSIGN api.headers["Content-Type"] "application/json" ;
ASSIGN api.timeout 10 ;
END FUNCTION