HTTP Client Functions
The client functions are used to exchange data with a HTTP/HTTPS server. There are specific functions for GET and POST as well as functions for general HTTP requests. Either plain text or encrypted communication can be used. Basic authentication is supported, as well as the use of a keystore, and if required a truststore, for the functions with an encrypted communication channel.
The HTTP client functions also support the use of proxy, see HTTP Proxy Support for information on how to setup HTTP proxy support.
Before using APL functions with TLS/SSL Encryption, refer to configuration required in HTTP Client Functions | TLS/SSL Encryption
The following functions for HTTP Client described here are:
- 1 httpGetURL
- 2 httpBinaryGetURL
- 3 httpGetSecureURL
- 4 httpBinaryGetSecureURL
- 5 httpPostURL
- 6 httpBinaryPostURL
- 7 httpPostSecureURL
- 8 httpBinaryPostSecureURL
- 9 httpRequest
- 10 httpRequestBasicAuth
- 11 httpRequestSecureBasicAuth
- 12 httpRequestSecure
- 13 httpRequestDigestAuth
- 14 httpCreateMultipartBody
- 15 httpAddMultipartSegment
- 16 httpAddMultipartSegmentWithMapping
- 17 httpMultipartPostURL
- 18 httpMultipartPostSecureURL
- 19 TLS/SSL Encryption
httpGetURL
This function uses the GET method to retrieve content from an HTTP server.
string httpGetURL
( string query,
string host,
int timeout,
int port, //Optional
string username, //Optional
string password, //Optional
map<string, string> headers, //Optional
int connectTimeout) //OptionalParameter | Description |
|---|---|
| The query including path Example - query/api/v2/doc/1
/api/v2/doc?id=1 |
| The name or IP address where the HTTP server is running |
| The number of seconds to wait for a response. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
| The port number to contact the HTTP server on. Port 80 is used by default. |
| A username for an account on the HTTP server |
| Password associated with the username |
| Custom HTTP request headers. |
| The number of seconds to wait for a connection to be established. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
Returns | Content from the HTTP server. It will be |
httpBinaryGetURL
This function uses the GET method to retrieve binary content from an HTTP server.
bytearray httpBinaryGetURL
( string query,
string host,
int timeout,
int port, //Optional
string username, //Optional
string password, //Optional
map<string, string> headers, //Optional
int connectTimeout) //OptionalParameter | Description |
|---|---|
| The query including path Example - query/api/v2/img/1
/api/v2/img?id=1 |
| The name or IP address where the HTTP server is running |
| The number of seconds to wait for a response. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
| The port number to contact the HTTP server on. Port 80 is used by default. |
| A username for an account on the HTTP server |
| Password associated with the username |
| Custom HTTP request headers. |
| The number of seconds to wait for a connection to be established. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
Returns | A bytearray from the HTTP server. It will be |
httpGetSecureURL
This function uses the GET method to retrieve content from an HTTPS server. The communication channel is encrypted.
string httpGetSecureURL
( string query,
string host,
int timeout,
int port, //Optional
string username //Optional
string password, //Optional
map<string, string> headers, //Optional
int connectTimeout) //OptionalParameter | Description |
|---|---|
| The query including path Example - query/api/v2/doc/1
/api/v2/doc?id=1 |
| The name or IP address where the HTTPS server is running |
| The number of seconds to wait for a response. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
| The port number to contact the HTTPS server on. Port 443 is used by default. |
| A username for an account on the HTTP server |
| Password associated with the username |
| Custom HTTP request headers. |
| The number of seconds to wait for a connection to be established. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
Returns | Content from the HTTPS server. It will be |
See the section below, TLS/SSL Encryption.
httpBinaryGetSecureURL
This function uses the GET method to retrieve binary content from an HTTPS server. The communication channel is encrypted.
bytearray httpBinaryGetSecureURL
( string query,
string host,
int timeout,
int port, //Optional
string username //Optional
string password, //Optional
map<string, string> headers, //Optional
int connectTimeout) //OptionalParameter | Description |
|---|---|
| The query including path Example - query/api/v2/img/1
/api/v2/img?id=1 |
| The name or IP address where the HTTPS server is running |
| The number of seconds to wait for a response. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
| The port number to contact the HTTPS server on. Port 443 is used by default. |
| A username for an account on the HTTP server |
| Password associated with the username |
| Custom HTTP request headers. |
| The number of seconds to wait for a connection to be established. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
Returns | A bytearray from the HTTPS server. It will be |
See the section below, TLS/SSL Encryption.
httpPostURL
This function uses the POST method to send content to an HTTP server and receives the response.
string httpPostURL
( string path,
string contentType,
string content,
string host,
int timeout,
int port, //Optional
string username, //Optional
string password, //Optional
map<string, string> headers, //Optional
int connectTimeout) //OptionalParameter | Description |
|---|---|
| The path Example - path/api/v2/doc
|
| The MIME type of the content Example - contentType/application/json
|
| The body of the request |
| The name or IP address where the HTTP server is running |
| The number of seconds to wait for a response. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
| The port number to contact the HTTP server on. Port 80 is used by default. |
| A username for an account on the HTTP server |
| Password associated with the username |
| Custom HTTP request headers. |
| The number of seconds to wait for a connection to be established. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
Returns | Content from the HTTP server. It will be |
httpBinaryPostURL
This function uses the POST method to send binary content to an HTTP server and receives the response.
bytearray httpBinaryPostURL
( string path,
string contentType,
bytearray content,
string host,
int timeout,
int port, //Optional
string username, //Optional
string password, //Optional
map<string, string> headers, //Optional
int connectTimeout) //OptionalParameter | Description |
|---|---|
| The path Example - path/api/v2/img
e |
| The MIME type of the content Example - contentType/application/octet-stream
|
| The body of the request |
| The name or IP address where the HTTP server is running |
| The number of seconds to wait for a response. If the value is set to 0 (zero), the default timeout will be used. Default value is 15 seconds. |
| The port number to contact the HTTP server on. Port 80 is used by default. |
| A username for an account on the HTTP server |
| Password associated with the username |
| Custom HTTP request headers. |
| The number of seconds to wait for a connection to be established. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
Returns | A bytearray from the HTTP server. It will be |
httpPostSecureURL
This function uses the POST method to send content to an HTTPS server and receives the response. The communication channel is encrypted.
string httpPostSecureURL
( string path,
string contentType,
string content,
string host,
int timeout,
int port, //Optional
string username, //Optional
string password, //Optional
map<string, string> headers, //Optional
int connectTimeout) //OptionalParameter | Description |
|---|---|
| The path Example - path/api/v2/doc
|
| The MIME type of the content Example - contentType/application/json
|
| The body of the request |
| The name or IP address where the HTTPS server is running |
| The number of seconds to wait for a response. If the value is set to 0 (zero), the default timeout will be used. Default value is 15 seconds. |
| The port number to contact the HTTPS server on. Port 443 is used by default. |
| A username for an account on the HTTP server |
| Password associated with the username |
| Custom HTTP request headers. |
| The number of seconds to wait for a connection to be established. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
Returns | A document from the HTTP server. It will be |
See the section below, TLS/SSL Encryption.
httpBinaryPostSecureURL
This function uses the POST method to send binary content to an HTTP server and receives the response. The communication channel is encrypted.
bytearray httpBinaryPostSecureURL
( string path,
string contentType,
bytearray content,
string host,
int timeout,
int port, //Optional
string username, //Optional
string password, //Optional
map<string, string> headers, //Optional
int connectTimeout) //OptionalParameter | Description |
|---|---|
| The path Example - path/api/v2/img
|
| The MIME type of the content Example - contentType/application/octet-stream
|
| The body of the request |
| The name or IP address where the HTTPS server is running |
| The number of seconds to wait for a response. If the value is set to 0 (zero), the default timeout will be used. Default value is 15 seconds. |
| The port number to contact the HTTPS server on. Port 443 is used by default. |
| A username for an account on the HTTP server |
| Password associated with the username |
| Custom HTTP request headers. |
| The number of seconds to wait for a connection to be established. If the value is set to 0 (zero), the default timeout will be used. The default value is 15 seconds. |
Returns | A bytearray from the HTTP server. It will be |
See the section below, TLS/SSL Encryption.
httpRequest
This function makes an HTTP request and uses the specified method, e g GET, POST, PUT etc.
string httpRequest
( string method,
string url,
map<string, string> headers,
string path,
string content,
string contentType,
list dynamicArgs) //OptParameter | Description |
|---|---|
| The HTTP method |
| The host and port of the HTTP server, e g http://host:port |
| Key-value pairs containing request header fields |
| The path Example - path/api
|
| The body of the request. |
| The MIME type of the content Example - contentType/application/json
|
dynamicArgs | The body of the request |
httpRequestBasicAuth
This function makes an HTTP request with basic authentication and uses the specified method, e g GET, POST, PUT etc.
string httpRequestBasicAuth
( string method,
string url,
map<string,string> header,
string contentType,
string content,
int timeout,
string username
string password,
int connectTimeout) //Optional