OScript API/Built-in Package Index |
The built-in functions in the RestClient class provide the ability to connect to a HTTP server and send get or post with content requests.
The RestClient class offers the following functionality:
Cookie Handling:
The RestClient has special handling for cookies. This applies to the functions: Get(), Post(), PostFile(), Delete(), Put(), PutFile(), Patch()
In order to send one or more cookies, a special Assoc of 'cookie name' - 'cookie value' pairs can be used. This special Assoc should be added to the headersFields Assoc parameter under a key named 'cookies'.
eg:
Assoc cookiesAssoc = { 'LLCookie' : 'asbvigh...vbirghbqit', 'mycookie' : 'sdv139...874to8qv' }
Assoc headersFields = Assoc{ 'cookies' : cookiesAssoc }
When the RestClient receives multiple cookies from the server, they are returned in a similar Assoc with 'cookie name' - 'cookie value' pairs under the key 'cookies' in the return Assoc from the function. They are not part of the responseHeaders Assoc. The 'cookies' Assoc is a sibling to the responseHeaders Assoc.
The name of the server
The URI
The port to connect to the server
The request timeout in seconds (default 200)
Returns a new RestClient instance, or undefined if an error occured.
Returns a new RestClient instance for HTTPS, or undefined if an error occured.
Returns a new RestClient instance for HTTPS, or undefined if an error occured.
Adds user and password/cert authentication.
Sends an HTTP delete.
Sends an HTTP get.
Get the current URI.
Sends an HTTP patch.
Sends an HTTP post.
Sends an HTTP post with local file reference to upload with the request.
Sends an HTTP put.
Sends an HTTP put with local file reference to upload with the request.
Set the Content-Type HTTP header.
Set the filename where content is written.
Set logging of headers at debug level. Headers are not logged by default.
Defines the host/port for a proxy server.
Set the user and password for a proxy server.
Set the URI.
The name of the server
The URI
The port to connect to the server
The request timeout in seconds (default 200)
Returns a new RestClient object.
IP address or domain name of HTTP host.
HTTP connection port, required
The base URI
Request timeout, default 200, min value 15
A new RestClient object or undefined if there was an error constructing the object.
Returns a new RestClient object. Client verification of target server certificate is performed with system certificate store. Legacy parameters 5 through 7 ignored, see NewSecureWithCerts.
IP address or domain name of HTTP host.
HTTP connection port, required
The base URI
Request timeout, default 200, min value 15
A new RestClient object or undefined if there was an error constructing the object.
Returns a new RestClient object. Allows alternate client certificate store to be specified. On Linux, certPath parameter is required for target server certificate validation.
IP address or domain name of HTTP host.
HTTP connection port, required
The base URI
Request timeout, default 200, min value 15
Linux only. The path to default keystore, usually /etc/ssl/certs. Pass an empty string to enable target server verification with system certificate store. If not specified, verification of target server certificate disabled. On Windows, root certificates are ALWAYS loaded from the system store and used for verification of target server certificate.
Used only for client certificate authentication by target server. The path of the client certificate file. This file must contain a complete certificate chain and be encoded in PEM format.
Used only for client certificate authentication by target server. The path of the client private key file. If this file contains both the key and certificate, then certFile parameter is not required.
A new RestClient object or undefined if there was an error constructing the object.
Adds authentication to the request and sends it if the server returns an authentication required http response.
The username for authentication
The password or certificate for authentication
0 if successful or undefined if an error
Constructs the header using the initialURI and supplied list of parm=value pairs and sends a delete.
Assoc of key value pairs to add to the URL query string (will URL encode if required)
Assoc of key value pairs to add additional fields to the HTTP header
Request return or error with message
Constructs the header using the initialURI and supplied Assoc of parm=value pairs and sends a get.
Assoc of key value pairs to add to the URL query string (will URL encode if required)
Assoc of key value pairs to add additional fields to the HTTP header
Request return or error with message
Constructs the header using the initialURI and supplied Assoc of parm=value pairs and sends a patch.
Assoc of key value pairs to add to the URL query string (will URL encode if required)
String containing patch content, may contain binary data
Length of the body content
Assoc of key value pairs to add additional fields to the HTTP header
Request return or error with message
Constructs the header using the initialURI and supplied Assoc of parm=value pairs and sends a post.
Assoc of key value pairs to add to the URL query string (will URL encode if required)
String containing post content, may contain binary data
Length of the body content
Assoc of key value pairs to add additional fields to the HTTP header
Assoc of key value pairs to send as HTTP POST parameters. NOTE: Should NOT be URL escaped. This can only be specified if the body is empty and length is 0.
Request return or error with message
Sends the given file as a HTTP multipart message
Assoc of key value pairs to add to the URL query string (will URL encode if required)
The fully qualified path to the local file that is to be uploaded
The file name to be used for the HTML form element (may be different than the local filename)
The HTML form element name associated with the file
The content or MIME type of the file
Assoc of key value pairs to add additional fields to the HTTP header
Assoc of key value pairs to send as HTTP multipart POST parameters. NOTE: Should NOT be URL escaped.
Request return or error with message
Constructs the header using the initialURI and supplied Assoc of parm=value pairs and sends a put.
Assoc of key value pairs to add to the URL query string (will URL encode if required)
String containing put content, may contain binary data
Length of the body content
Assoc of key value pairs to add additional fields to the HTTP header
Assoc of key value pairs to send as HTTP multipart PUT parameters. NOTE: Should NOT be URL escaped.
Request return or error with message
Sends the given file as a HTTP multipart message
Assoc of key value pairs to add to the URL query string (will URL encode if required)
The fully qualified path to the local file that is to be uploaded
The file name to be used for the HTML form element (may be different than the local filename)
The HTML form element name associated with the file
The content or MIME type of the file
Assoc of key value pairs to add additional fields to the HTTP header
Assoc of key value pairs to send as HTTP multipart PUT parameters. NOTE: Should NOT be URL escaped.
Request return or error with message
Set the Content-Type HTTP header for all requests sent by this client.
The value of the header
0 or undefined
Allows larger content from the server to be written to a file instead of returning it in the Assoc.
String containing the file path/name
0 or undefined
Enable/disable logging of headers at debug level. Note: passwords will be visible.
Log headers on/off
0 or undefined
If set, the connection will be routed through the specified proxy server.
IP address or domain name of proxy host.
Proxy connection port, required
0 if successful or undefined if an error occurred.
If a proxy server is specified, this is the authentication for the proxy server.
The username for authentication
The passwordfor authentication
0 if successful or undefined if an error
Sets the URI to a new value.
The URI
0 or undefined
Copyright © 2022 OpenText Corporation. All rights reserved. |