Rest Delphi DLL Reference Documentation

Rest

Current Version: 10.1.0

API for implementing RESTful Web API's.

Create/Dispose

var
myObject: HCkRest;

begin
myObject := CkRest_Create();

// ...

CkRest_Dispose(myObject);
end;
function CkRest_Create: HCkRest; stdcall;

Creates an instance of the HCkRest object and returns a handle (i.e. a Pointer). The handle is passed in the 1st argument for the functions listed on this page.

procedure CkRest_Dispose(handle: HCkRest); stdcall;

Objects created by calling CkRest_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

Properties

AllowHeaderFolding
function CkRest_getAllowHeaderFolding(objHandle: HCkRest): wordbool; stdcall;
procedure CkRest_putAllowHeaderFolding(objHandle: HCkRest; newPropVal: wordbool); stdcall;
Introduced in version 9.5.0.63

If this property is set to False, then no MIME header folding will be automatically applied to any request header. The default is True. This property is provided to satisfy certain providers, such as Quickbooks, that require all MIME headers to be single unfolded lines regardless of length.

top
AllowHeaderQB
function CkRest_getAllowHeaderQB(objHandle: HCkRest): wordbool; stdcall;
procedure CkRest_putAllowHeaderQB(objHandle: HCkRest; newPropVal: wordbool); stdcall;
Introduced in version 9.5.0.59

Controls whether non us-ascii HTTP request headers are automatically Q/B encoded. The default value is True.

Q/B encoded headers explicitly indicate the charset and byte representation, and appear as such: =?utf-8?Q?...?= or =?utf-8?B?...?=, where the charset may be "utf-8" or any other possible charset.

If this property is set to False, then no Q/B encoding is applied to any request header.

top
Authorization
procedure CkRest_getAuthorization(objHandle: HCkRest; outPropVal: HCkString); stdcall;
procedure CkRest_putAuthorization(objHandle: HCkRest; newPropVal: PWideChar); stdcall;
function CkRest__authorization(objHandle: HCkRest): PWideChar; stdcall;
Introduced in version 9.5.0.58

The value of the Authorization HTTP request header (if needed).

See the notes about PWideChar memory ownership and validity.

top
ConnectFailReason
function CkRest_getConnectFailReason(objHandle: HCkRest): Integer; stdcall;
Introduced in version 9.5.0.58

If the Connect method fails, this property can be checked to determine the reason for failure.

Possible values are:

0 = success

Normal (non-SSL) sockets:
1 = empty hostname
2 = DNS lookup failed
3 = DNS timeout
4 = Aborted by application.
5 = Internal failure.
6 = Connect Timed Out
7 = Connect Rejected (or failed for some other reason)
99 = Chilkat not unlocked / trial expired.

SSL/TLS:
100 = TLS internal error.
101 = Failed to send client hello.
102 = Unexpected handshake message.
103 = Failed to read server hello.
104 = No server certificate.
105 = Unexpected TLS protocol version.
106 = Server certificate verify failed (the server certificate is expired or the cert's signature verification failed).
107 = Unacceptable TLS protocol version.
109 = Failed to read handshake messages.
110 = Failed to send client certificate handshake message.
111 = Failed to send client key exchange handshake message.
112 = Client certificate's private key not accessible.
113 = Failed to send client cert verify handshake message.
114 = Failed to send change cipher spec handshake message.
115 = Failed to send finished handshake message.
116 = Server's Finished message is invalid.

top
ConnectTimeoutMs
function CkRest_getConnectTimeoutMs(objHandle: HCkRest): Integer; stdcall;
procedure CkRest_putConnectTimeoutMs(objHandle: HCkRest; newPropVal: Integer); stdcall;
Introduced in version 9.5.0.71

The maximum amount of time to wait for the connection to be accepted by the HTTP server.

top
DebugLogFilePath
procedure CkRest_getDebugLogFilePath(objHandle: HCkRest; outPropVal: HCkString); stdcall;
procedure CkRest_putDebugLogFilePath(objHandle: HCkRest; newPropVal: PWideChar); stdcall;
function CkRest__debugLogFilePath(objHandle: HCkRest): PWideChar; stdcall;

If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.

This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes). A hang or crash should generally never happen. The typical causes of a hang are:

  1. a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,
  2. the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or
  3. there is an internal problem (bug) in the Chilkat code that causes the hang.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
DebugMode
function CkRest_getDebugMode(objHandle: HCkRest): wordbool; stdcall;
procedure CkRest_putDebugMode(objHandle: HCkRest; newPropVal: wordbool); stdcall;
Introduced in version 9.5.0.77

If True then all calls to Send* or FullRequest* methods will not actually send a request. Instead, the request will be written to a memory buffer which can then be retrieved by calling GetLastDebugRequest.

More Information and Examples
top
HeartbeatMs
function CkRest_getHeartbeatMs(objHandle: HCkRest): Integer; stdcall;
procedure CkRest_putHeartbeatMs(objHandle: HCkRest; newPropVal: Integer); stdcall;
Introduced in version 9.5.0.58

This property is only valid in programming environment and languages that allow for event callbacks.

Specifies the time interval in milliseconds between AbortCheck events. A value of 0 (the default) indicate that no AbortCheck events will fire. Any REST method can be aborted via the AbortCheck event.

top
Host
procedure CkRest_getHost(objHandle: HCkRest; outPropVal: HCkString); stdcall;
procedure CkRest_putHost(objHandle: HCkRest; newPropVal: PWideChar); stdcall;
function CkRest__host(objHandle: HCkRest): PWideChar; stdcall;
Introduced in version 9.5.0.58

The value of the Host HTTP request header.

See the notes about PWideChar memory ownership and validity.

top
IdleTimeoutMs
function CkRest_getIdleTimeoutMs(objHandle: HCkRest): Integer; stdcall;
procedure CkRest_putIdleTimeoutMs(objHandle: HCkRest; newPropVal: Integer); stdcall;
Introduced in version 9.5.0.58

The maximum amount of time to wait for additional incoming data when receiving, or the max time to wait to send additional data. The default value is 30000 (30 seconds). This is not an overall max timeout. Rather, it is the maximum time to wait when receiving or sending has halted.

top
LastErrorHtml
procedure CkRest_getLastErrorHtml(objHandle: HCkRest; outPropVal: HCkString); stdcall;
function CkRest__lastErrorHtml(objHandle: HCkRest): PWideChar; stdcall;

Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

See the notes about PWideChar memory ownership and validity.

top
LastErrorText
procedure CkRest_getLastErrorText(objHandle: HCkRest; outPropVal: HCkString); stdcall;
function CkRest__lastErrorText(objHandle: HCkRest): PWideChar; stdcall;

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

See the notes about PWideChar memory ownership and validity.

top
LastErrorXml
procedure CkRest_getLastErrorXml(objHandle: HCkRest; outPropVal: HCkString); stdcall;
function CkRest__lastErrorXml(objHandle: HCkRest): PWideChar; stdcall;

Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

See the notes about PWideChar memory ownership and validity.

top
LastMethodSuccess
function CkRest_getLastMethodSuccess(objHandle: HCkRest): wordbool; stdcall;
procedure CkRest_putLastMethodSuccess(objHandle: HCkRest; newPropVal: wordbool); stdcall;

Indicate whether the last method call succeeded or failed. A value of True indicates success, a value of False indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:

  • Any method that returns a string.
  • Any method returning a Chilkat object, binary bytes, or a date/time.
  • Any method returning a standard boolean status value where success = True and failure = False.
  • Any method returning an integer where failure is defined by a return value less than zero.

Note: Methods that do not fit the above requirements will always set this property equal to True. For example, a method that returns no value (such as a "void" in C++) will technically always succeed.

top
LastRequestHeader
procedure CkRest_getLastRequestHeader(objHandle: HCkRest; outPropVal: HCkString); stdcall;
function CkRest__lastRequestHeader(objHandle: HCkRest): PWideChar; stdcall;
Introduced in version 9.5.0.58

The full MIME header (not including the HTTP start line which contains the status code and status text), of the last request sent.

See the notes about PWideChar memory ownership and validity.

top
LastRequestStartLine
procedure CkRest_getLastRequestStartLine(objHandle: HCkRest; outPropVal: HCkString); stdcall;
function CkRest__lastRequestStartLine(objHandle: HCkRest): PWideChar; stdcall;
Introduced in version 9.5.0.58

The full start line of the last request sent. (The start line begins with the HTTP verb, such as GET, POST, etc., is followed by the URI path, and ends with the HTTP version.)

See the notes about PWideChar memory ownership and validity.

top
NumResponseHeaders
function CkRest_getNumResponseHeaders(objHandle: HCkRest): Integer; stdcall;
Introduced in version 9.5.0.58

The number of response header fields. The first response header field is at index 0.

top
PartSelector
procedure CkRest_getPartSelector(objHandle: HCkRest; outPropVal: HCkString); stdcall;
procedure CkRest_putPartSelector(objHandle: HCkRest; newPropVal: PWideChar); stdcall;
function CkRest__partSelector(objHandle: HCkRest): PWideChar; stdcall;
Introduced in version 9.5.0.58

Only used for multipart requests. Selects the target MIME part for calls to AddHeader, RemoveHeader, SetMultipartBodyBinary, SetMultipartBodyString, SetMultipartBodyStream, etc. The default is an empty string and indicates the top-level header. A string value of "1" would indicate the 1st sub-part in a multipart request. A string value of "1.2" would indicate the 2nd sub-part under the 1st sub-part.

It is unlikely you'll ever encounter the need for nested multipart requests (i.e. part selectors such as "1.2") Also, most REST requests are NOT multipart, and therefore this feature is rarely used. An example of a multipart REST request would be for a Google Drive upload, where the top-level Content-Type is multipart/related, the1st sub-part contains the JSON meta-data, and the 2nd sub-part contains the file data.

See the notes about PWideChar memory ownership and validity.

top
PercentDoneOnSend
function CkRest_getPercentDoneOnSend(objHandle: HCkRest): wordbool; stdcall;
procedure CkRest_putPercentDoneOnSend(objHandle: HCkRest; newPropVal: wordbool); stdcall;
Introduced in version 9.5.0.58

This property only applies to the FullRequest* methods, which are methods that both send an HTTP request and receive the response. (It also only applies to programming languages that support event callbacks.) It determines whether percentage completion is tracked for the sending of the HTTP request, or for the downloading the HTTP response. The default value is False, which is to measure the percent completion when receiving the response.

For example: If the REST request is to download a file, then this property should remain at the default value of False. If the REST request is to upload a file (using a Full* method), then set this property to True. Also note if a server sends an HTTP response in the chunked encoding, it is not possible to measure percent completion because the HTTP client has no way of knowing the total size of the HTTP response.

top
ResponseHeader
procedure CkRest_getResponseHeader(objHandle: HCkRest; outPropVal: HCkString); stdcall;
function CkRest__responseHeader(objHandle: HCkRest): PWideChar; stdcall;
Introduced in version 9.5.0.58

The full response MIME header (not including the HTTP start line which contains the status code and status text).

See the notes about PWideChar memory ownership and validity.

top
ResponseStatusCode
function CkRest_getResponseStatusCode(objHandle: HCkRest): Integer; stdcall;
Introduced in version 9.5.0.58

The response status code.

More Information and Examples
top
ResponseStatusText
procedure CkRest_getResponseStatusText(objHandle: HCkRest; outPropVal: HCkString); stdcall;
function CkRest__responseStatusText(objHandle: HCkRest): PWideChar; stdcall;
Introduced in version 9.5.0.58

The status message corresponding to the response status code.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
StreamNonChunked
function CkRest_getStreamNonChunked(objHandle: HCkRest): wordbool; stdcall;
procedure CkRest_putStreamNonChunked(objHandle: HCkRest; newPropVal: wordbool); stdcall;
Introduced in version 9.5.0.58

If True, then methods that upload data are sent non-chunked if possible. For example, if the FullRequestStream method is called where the stream is a file stream, then the size of the content is known and the HTTP request will be sent using a Content-Length header instead of using a Transfer-Encoding: chunked upload. If False, then the chunked transfer encoding is used. The default value of this property is True.

top
UncommonOptions
procedure CkRest_getUncommonOptions(objHandle: HCkRest; outPropVal: HCkString); stdcall;
procedure CkRest_putUncommonOptions(objHandle: HCkRest; newPropVal: PWideChar); stdcall;
function CkRest__uncommonOptions(objHandle: HCkRest): PWideChar; stdcall;
Introduced in version 9.5.0.80

This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty. Can be set to a list of the following comma separated keywords:

  • AllowDuplicateQueryParams - Affects the AddQueryParam method. If the query parameter to be added already exists, it is not replaced and instead an additional param with the same name is added.
  • AllowInsecureBasicAuth - Introduced in v9.5.0.80. Allows HTTP Basic authentication over non-TLS connections. (HTTP Basic authentication puts the login:password in the Authorization header field in base64 encoding. If transmitted over an insecure connection, it is potentially visible to anything sniffing the traffic. By default, Chilkat disallows HTTP Basic authentication except for SSL/TLS connections, SSH tunneled connections, or connections to localhost.)
  • DisableTls13 Disables TLS 1.3 so that only TLS 1.2 or lower is used.
  • ProtectFromVpn - Introduced in v9.5.0.80. On Android systems, will bypass any VPN that may be installed or active.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
VerboseLogging
function CkRest_getVerboseLogging(objHandle: HCkRest): wordbool; stdcall;
procedure CkRest_putVerboseLogging(objHandle: HCkRest; newPropVal: wordbool); stdcall;

If set to True, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is False. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
procedure CkRest_getVersion(objHandle: HCkRest; outPropVal: HCkString); stdcall;
function CkRest__version(objHandle: HCkRest): PWideChar; stdcall;

Version of the component/library, such as "9.5.0.94"

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top

Methods

AddHeader
function CkRest_AddHeader(objHandle: HCkRest;
    name: PWideChar;
    value: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Adds an HTTP request header. If the header field already exists, then it is replaced.

Returns True for success, False for failure.

top
AddMwsSignature
function CkRest_AddMwsSignature(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    domain: PWideChar;
    mwsSecretKey: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.66

Computes the Amazon MWS signature using the mwsSecretKey and adds the "Signature" parameter to the request. This method should be called for all Amazon Marketplace Web Service (Amazon MWS) HTTP requests. It should be called after all request parameters have been added.

Important: The Chilkat v9.5.0.75 release accidentally breaks Amazon MWS (not AWS) authentication. If you need MWS with 9.5.0.75, send email to support@chilkatsoft.com for a hotfix, or revert back to v9.5.0.73, or update to a version after 9.5.0.75.

The domain should be the domain of the request, such as one of the following:

  • mws.amazonservices.com
  • mws-eu.amazonservices.com
  • mws.amazonservices.in
  • mws.amazonservices.com.cn
  • mws.amazonservices.jp

The httpVerb should be the HTTP verb, such as "GET", "POST", etc. The uriPath is the URI path, such as "/Feeds/2009-01-01". In general, the httpVerb and uriPath should be identical to the 1st two args passed to methods such as FullRequestFormUrlEncoded.

Note: This method also automatically adds or replaces the existing Timestamp parameter to the current system date/time.

Returns True for success, False for failure.

top
AddPathParam
function CkRest_AddPathParam(objHandle: HCkRest;
    name: PWideChar;
    value: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.70

Adds or replaces a path parameter. A path parameter is a string that will be replaced in any uriPath string passed to a method. For example, if name is "fileId" and value is "1R_70heIyzIAu1_u0prXbYcaIiJRVkgBl", then a uriPath argument of "/drive/v3/files/fileId" will be transformed to "/drive/v3/files/1R_70heIyzIAu1_u0prXbYcaIiJRVkgBl" in a method call.

Returns True for success, False for failure.

More Information and Examples
top
AddQueryParam
function CkRest_AddQueryParam(objHandle: HCkRest;
    name: PWideChar;
    value: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Adds a query parameter. If the query parameter already exists, then it is replaced.

To allow duplicates, you can add the keyword "AllowDuplicateQueryParams" to the UncommonOptions property value. In other words, if the query parameter already exists, it is not replaced and instead an additional param with the same name is added.

Returns True for success, False for failure.

More Information and Examples
top
AddQueryParams
function CkRest_AddQueryParams(objHandle: HCkRest;
    queryString: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Adds the query parameters from the queryString. The queryString is a query string of the format field1=value1&field2=value2&field3=value3... where each value is URL encoded.

Returns True for success, False for failure.

More Information and Examples
top
AddQueryParamSb
function CkRest_AddQueryParamSb(objHandle: HCkRest;
    name: PWideChar;
    value: HCkStringBuilder): wordbool; stdcall;
Introduced in version 9.5.0.62

Adds a query parameter. If the query parameter already exists, then it is replaced. The parameter value is passed in a StringBuilder object.

Returns True for success, False for failure.

top
ClearAllHeaders
function CkRest_ClearAllHeaders(objHandle: HCkRest): wordbool; stdcall;
Introduced in version 9.5.0.58

Removes all HTTP request headers.

Returns True for success, False for failure.

top
ClearAllParts
function CkRest_ClearAllParts(objHandle: HCkRest): wordbool; stdcall;
Introduced in version 9.5.0.64

Removes all sub-parts from a request. This is useful when preparing the REST object to send a new request after a multipart request has just been sent.

Returns True for success, False for failure.

More Information and Examples
top
ClearAllPathParams
function CkRest_ClearAllPathParams(objHandle: HCkRest): wordbool; stdcall;
Introduced in version 9.5.0.70

Clears all path parameters.

Returns True for success, False for failure.

top
ClearAllQueryParams
function CkRest_ClearAllQueryParams(objHandle: HCkRest): wordbool; stdcall;
Introduced in version 9.5.0.58

Clears all query parameters.

Returns True for success, False for failure.

top
ClearAuth
function CkRest_ClearAuth(objHandle: HCkRest): wordbool; stdcall;
Introduced in version 9.5.0.69

Clears all authentication settings.

Returns True for success, False for failure.

top
ClearResponseBodyStream
procedure CkRest_ClearResponseBodyStream(objHandle: HCkRest) stdcall;
Introduced in version 9.5.0.58

Clears the response body stream.

top
Connect
function CkRest_Connect(objHandle: HCkRest;
    hostname: PWideChar;
    port: Integer;
    tls: wordbool;
    autoReconnect: wordbool): wordbool; stdcall;
Introduced in version 9.5.0.58

Establishes an initial connection to a REST server. The hostname can be a domain name or an IP address. Both IPv4 and IPv6 addresses are supported. The port is the port, which is typically 80 or 443. If SSL/TLS is required, then tls should be set to True. The autoReconnect indicates whether connection should automatically be established as needed for subsequent REST requests.

Note: This method is for simple connections that do not require any proxies (HTTP or SOCKS), or SSH tunneling. If a proxy, SSH tunnel, or any other advanced socket feature is required, the Chilkat Socket API can be used to establish the connection. The UseConnection method can then be called to use the pre-established socket connection.

IMPORTANT: The hostname argument should be just the domain or IP address. It is NOT the full URL. If your URL is "https://www.example.com/something/123", then pass "www.example.com" in the 1st argument.

Returns True for success, False for failure.

top
ConnectAsync (1)
function CkRest_ConnectAsync(objHandle: HCkRest;
    hostname: PWideChar;
    port: Integer;
    tls: wordbool;
    autoReconnect: wordbool): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the Connect method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
Disconnect
function CkRest_Disconnect(objHandle: HCkRest;
    maxWaitMs: Integer): wordbool; stdcall;
Introduced in version 9.5.0.58

Closes the connection with the HTTP server if one is open. This method can be called to ensure the connection is closed. The maxWaitMs is the maximum time in milliseconds to wait for a clean close. If the connection is through an SSH tunnel, this closes the logical channel within the SSH tunnel, and not the connection with the SSH server itself.

Returns True for success, False for failure.

top
DisconnectAsync (1)
function CkRest_DisconnectAsync(objHandle: HCkRest;
    maxWaitMs: Integer): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the Disconnect method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestBd
function CkRest_FullRequestBd(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    binData: HCkBinData;
    responseBody: HCkStringBuilder): wordbool; stdcall;
Introduced in version 9.5.0.64

Sends a complete REST request (header + binary body) and receives the full response. The binary body of the request is passed in binData. The response body is returned in responseBody (replacing whatever contents responseBody may have previously held).

Note: If your application wishes to receive percent-done callbacks, make sure the PercentDoneOnSend property is set to indicate whether percent-done applies to sending or receiving.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

More Information and Examples
top
FullRequestBdAsync (1)
function CkRest_FullRequestBdAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    binData: HCkBinData;
    responseBody: HCkStringBuilder): HCkTask; stdcall;
Introduced in version 9.5.0.64

Creates an asynchronous task to call the FullRequestBd method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestBinary
function CkRest_FullRequestBinary(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodyBytes: HCkByteData;
    outStr: HCkString): wordbool; stdcall;
function CkRest__fullRequestBinary(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodyBytes: HCkByteData): PWideChar; stdcall;
Introduced in version 9.5.0.58

Sends a complete REST request (header + body) and receives the full response. It is assumed that the request body is binary, and the response body is a string (such as JSON or XML). The response body is returned.

This method is the equivalent of making the following calls in sequence: SendReqBinaryBody, ReadResponseHeader, ReadRespBodyString.

Note: If your application wishes to receive percent-done callbacks, make sure the PercentDoneOnSend property is set to indicate whether percent-done applies to sending or receiving.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
FullRequestBinaryAsync (1)
function CkRest_FullRequestBinaryAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodyBytes: HCkByteData): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestBinary method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestFormUrlEncoded
function CkRest_FullRequestFormUrlEncoded(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRest__fullRequestFormUrlEncoded(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): PWideChar; stdcall;
Introduced in version 9.5.0.58

Sends a complete application/x-www-form-urlencoded HTTP request and receives the full response. The request body is composed of the URL encoded query params. It is assumed that the response body is a string (such as JSON or XML). The response body is returned.

This method is the equivalent of making the following calls in sequence: SendReqFormUrlEncoded, ReadResponseHeader, ReadRespBodyString.

Note: If your application wishes to receive percent-done callbacks, make sure the PercentDoneOnSend property is set to indicate whether percent-done applies to sending or receiving.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
FullRequestFormUrlEncodedAsync (1)
function CkRest_FullRequestFormUrlEncodedAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestFormUrlEncoded method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestMultipart
function CkRest_FullRequestMultipart(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRest__fullRequestMultipart(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): PWideChar; stdcall;
Introduced in version 9.5.0.58

Sends a complete multipart REST request (header + multipart body) and receives the full response. It is assumed that the response body is a string (such as JSON or XML). The response body is returned.

This method is the equivalent of making the following calls in sequence: SendReqMultipart, ReadResponseHeader, ReadRespBodyString.

Note: If your application wishes to receive percent-done callbacks, make sure the PercentDoneOnSend property is set to indicate whether percent-done applies to sending or receiving.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
FullRequestMultipartAsync (1)
function CkRest_FullRequestMultipartAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestMultipart method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestNoBody
function CkRest_FullRequestNoBody(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRest__fullRequestNoBody(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): PWideChar; stdcall;
Introduced in version 9.5.0.58

Sends a complete REST request and receives the full response. It is assumed that the response body is a string (such as JSON or XML). The response body is returned.

This method is the equivalent of making the following calls in sequence: SendReqNoBody, ReadResponseHeader, ReadRespBodyString.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
FullRequestNoBodyAsync (1)
function CkRest_FullRequestNoBodyAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestNoBody method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestNoBodyBd
function CkRest_FullRequestNoBodyBd(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    binData: HCkBinData): wordbool; stdcall;
Introduced in version 9.5.0.64

The same as FullRequestNoBody, except returns the response body in the binData. This method is useful for downloading binary files.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

top
FullRequestNoBodyBdAsync (1)
function CkRest_FullRequestNoBodyBdAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    binData: HCkBinData): HCkTask; stdcall;
Introduced in version 9.5.0.64

Creates an asynchronous task to call the FullRequestNoBodyBd method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestNoBodySb
function CkRest_FullRequestNoBodySb(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    sb: HCkStringBuilder): wordbool; stdcall;
Introduced in version 9.5.0.64

The same as FullRequestNoBody, except returns the response body in the sb.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

top
FullRequestNoBodySbAsync (1)
function CkRest_FullRequestNoBodySbAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    sb: HCkStringBuilder): HCkTask; stdcall;
Introduced in version 9.5.0.64

Creates an asynchronous task to call the FullRequestNoBodySb method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestSb
function CkRest_FullRequestSb(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    requestBody: HCkStringBuilder;
    responseBody: HCkStringBuilder): wordbool; stdcall;
Introduced in version 9.5.0.62

Sends a complete REST request (header + body string) and receives the full response. The body of the request is passed in requestBody. The response body is returned in responseBody (replacing whatever contents responseBody may have previously held).

Note: If your application wishes to receive percent-done callbacks, make sure the PercentDoneOnSend property is set to indicate whether percent-done applies to sending or receiving.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

top
FullRequestSbAsync (1)
function CkRest_FullRequestSbAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    requestBody: HCkStringBuilder;
    responseBody: HCkStringBuilder): HCkTask; stdcall;
Introduced in version 9.5.0.62

Creates an asynchronous task to call the FullRequestSb method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestStream
function CkRest_FullRequestStream(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    stream: HCkStream;
    outStr: HCkString): wordbool; stdcall;
function CkRest__fullRequestStream(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    stream: HCkStream): PWideChar; stdcall;
Introduced in version 9.5.0.58

Sends a complete REST request and receives the full response. It is assumed that the response body is a string (such as JSON or XML). The response body is returned.

This method is the equivalent of making the following calls in sequence: SendReqStream, ReadResponseHeader, ReadRespBodyString.

Note: If your application wishes to receive percent-done callbacks, make sure the PercentDoneOnSend property is set to indicate whether percent-done applies to sending or receiving.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
FullRequestStreamAsync (1)
function CkRest_FullRequestStreamAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    stream: HCkStream): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestStream method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
FullRequestString
function CkRest_FullRequestString(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodyText: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRest__fullRequestString(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodyText: PWideChar): PWideChar; stdcall;
Introduced in version 9.5.0.58

Sends a complete REST request (header + body string) and receives the full response. It is assumed that both the request and response bodies are strings (such as JSON or XML). The response body is returned.

This method is the equivalent of making the following calls in sequence: SendReqStringBody, ReadResponseHeader, ReadRespBodyString.

Note: If your application wishes to receive percent-done callbacks, make sure the PercentDoneOnSend property is set to indicate whether percent-done applies to sending or receiving.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
FullRequestStringAsync (1)
function CkRest_FullRequestStringAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodyText: PWideChar): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestString method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
GetLastDebugRequest
function CkRest_GetLastDebugRequest(objHandle: HCkRest;
    bd: HCkBinData): wordbool; stdcall;
Introduced in version 9.5.0.77

Returns the fully composed HTTP request that would've been sent had the DebugMode been turned off. The request is returned in bd.

Returns True for success, False for failure.

More Information and Examples
top
LastJsonData
function CkRest_LastJsonData(objHandle: HCkRest): HCkJsonObject; stdcall;
Introduced in version 9.5.0.79

Provides information about what transpired in the last method called on this object instance. For many methods, there is no information. However, for some methods, details about what occurred can be obtained by getting the LastJsonData right after the method call returns.

Returns nil on failure

top
LoadTaskCaller
function CkRest_LoadTaskCaller(objHandle: HCkRest;
    task: HCkTask): wordbool; stdcall;
Introduced in version 9.5.0.80

Loads the caller of the task's async method.

Returns True for success, False for failure.

top
ReadRespBd
function CkRest_ReadRespBd(objHandle: HCkRest;
    responseBody: HCkBinData): wordbool; stdcall;
Introduced in version 9.5.0.62

Reads the response body. Should only be called after ReadResponseHeader has been called, and should only be called when it is already known that the response body is binary, such as for JPG images or other non-text binary file types. The response body is received into responseBody (replacing whatever contents responseBody may have previously held).

Returns True for success, False for failure.

top
ReadRespBdAsync (1)
function CkRest_ReadRespBdAsync(objHandle: HCkRest;
    responseBody: HCkBinData): HCkTask; stdcall;
Introduced in version 9.5.0.62

Creates an asynchronous task to call the ReadRespBd method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
ReadRespBodyBinary
function CkRest_ReadRespBodyBinary(objHandle: HCkRest;
    outBytes: HCkByteData): wordbool; stdcall;
Introduced in version 9.5.0.58

Reads the response body. Should only be called after ReadResponseHeader has been called, and should only be called when it is already known that the response body is binary, such as for JPG images or other non-text binary file types.

Returns True for success, False for failure.

More Information and Examples
top
ReadRespBodyBinaryAsync (1)
function CkRest_ReadRespBodyBinaryAsync(objHandle: HCkRest): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the ReadRespBodyBinary method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
ReadRespBodyStream
function CkRest_ReadRespBodyStream(objHandle: HCkRest;
    stream: HCkStream;
    autoSetStreamCharset: wordbool): wordbool; stdcall;
Introduced in version 9.5.0.58

Reads the response body to the stream. If autoSetStreamCharset is True, then the stream's StringCharset property will automatically get set based on the charset, if any, indicated in the response header. If the response is binary, then autoSetStreamCharset is ignored.

Returns True for success, False for failure.

top
ReadRespBodyStreamAsync (1)
function CkRest_ReadRespBodyStreamAsync(objHandle: HCkRest;
    stream: HCkStream;
    autoSetStreamCharset: wordbool): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the ReadRespBodyStream method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
ReadRespBodyString
function CkRest_ReadRespBodyString(objHandle: HCkRest;
    outStr: HCkString): wordbool; stdcall;
function CkRest__readRespBodyString(objHandle: HCkRest): PWideChar; stdcall;
Introduced in version 9.5.0.58

Reads the response body. Should only be called after ReadResponseHeader has been called, and should only be called when it is already known that the response body will be a string (such as XML, JSON, etc.)

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
ReadRespBodyStringAsync (1)
function CkRest_ReadRespBodyStringAsync(objHandle: HCkRest): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the ReadRespBodyString method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
ReadRespChunkBd
function CkRest_ReadRespChunkBd(objHandle: HCkRest;
    minSize: Integer;
    bd: HCkBinData): Integer; stdcall;
Introduced in version 10.1.0

Reads the a chunk of the response. The received data is appended to bd. Will not return until at least minSize bytes are received. The last chunk of the response may be less than minSize bytes, or even 0 bytes.

Returns one of the following values:

  • -1 - Failed. Check the contents of the LastErrorText for more information.
  • 0 - Successfully returned the remaining bytes of the response.
  • 1 - Returned a chunk of response bytes. The response is not yet finished.

Returns True for success, False for failure.

More Information and Examples
top
ReadRespChunkBdAsync (1)
function CkRest_ReadRespChunkBdAsync(objHandle: HCkRest;
    minSize: Integer;
    bd: HCkBinData): HCkTask; stdcall;
Introduced in version 10.1.0

Creates an asynchronous task to call the ReadRespChunkBd method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
ReadResponseHeader
function CkRest_ReadResponseHeader(objHandle: HCkRest): Integer; stdcall;
Introduced in version 9.5.0.58

Reads the HTTP response header. If the HTTP response includes a body, then the application must call the desired method to read the response body. Otherwise, the HTTP request / response is finished after reading the response header (such as for a GET request). The contents of the response header are available in various properties and methods.

The HTTP response status code is returned (such as 200 for a typical success response). If an error occurred such that no response was received, then a value of -1 is returned.

More Information and Examples
top
ReadResponseHeaderAsync (1)
function CkRest_ReadResponseHeaderAsync(objHandle: HCkRest): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the ReadResponseHeader method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
ReadRespSb
function CkRest_ReadRespSb(objHandle: HCkRest;
    responseBody: HCkStringBuilder): wordbool; stdcall;
Introduced in version 9.5.0.62

Reads the response body. Should only be called after ReadResponseHeader has been called, and should only be called when it is already known that the response body will be a string (such as XML, JSON, etc.) The response body is stored in responseBody. (replacing whatever contents responseBody may have previously held).

Returns True for success, False for failure.

top
ReadRespSbAsync (1)
function CkRest_ReadRespSbAsync(objHandle: HCkRest;
    responseBody: HCkStringBuilder): HCkTask; stdcall;
Introduced in version 9.5.0.62

Creates an asynchronous task to call the ReadRespSb method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
RedirectUrl
function CkRest_RedirectUrl(objHandle: HCkRest): HCkUrl; stdcall;
Introduced in version 9.5.0.58

If the response was a redirect and contains a Location header field, this method returns the redirect URL.

Returns nil on failure

More Information and Examples
top
RemoveHeader
function CkRest_RemoveHeader(objHandle: HCkRest;
    name: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Removes all headers having the given name.

Returns True for success, False for failure.

top
RemoveQueryParam
function CkRest_RemoveQueryParam(objHandle: HCkRest;
    name: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Removes all query params having the given name.

Returns True for success, False for failure.

top
ResponseHdrByName
function CkRest_ResponseHdrByName(objHandle: HCkRest;
    name: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRest__responseHdrByName(objHandle: HCkRest;
    name: PWideChar): PWideChar; stdcall;
Introduced in version 9.5.0.58

Returns the value of the response header indicated by name.

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
ResponseHdrName
function CkRest_ResponseHdrName(objHandle: HCkRest;
    index: Integer;
    outStr: HCkString): wordbool; stdcall;
function CkRest__responseHdrName(objHandle: HCkRest;
    index: Integer): PWideChar; stdcall;
Introduced in version 9.5.0.58

Returns the name of the Nth response header field. (Chilkat always uses 0-based indexing. The first header field is at index 0.)

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
ResponseHdrValue
function CkRest_ResponseHdrValue(objHandle: HCkRest;
    index: Integer;
    outStr: HCkString): wordbool; stdcall;
function CkRest__responseHdrValue(objHandle: HCkRest;
    index: Integer): PWideChar; stdcall;
Introduced in version 9.5.0.58

Returns the value of the Nth response header field. (Chilkat always uses 0-based indexing. The first header field is at index 0.)

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
SendReqBd
function CkRest_SendReqBd(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    body: HCkBinData): wordbool; stdcall;
Introduced in version 9.5.0.62

Sends a REST request that cotnains a binary body. The httpVerb is the HTTP verb (also known as the HTTP method), such as "PUT". The uriPath is the path of the resource URI. The body contains the bytes of the HTTP request body.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

top
SendReqBdAsync (1)
function CkRest_SendReqBdAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    body: HCkBinData): HCkTask; stdcall;
Introduced in version 9.5.0.62

Creates an asynchronous task to call the SendReqBd method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
SendReqBinaryBody
function CkRest_SendReqBinaryBody(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    body: HCkByteData): wordbool; stdcall;
Introduced in version 9.5.0.58

Sends a REST request that cotnains a binary body. The httpVerb is the HTTP verb (also known as the HTTP method), such as "PUT". The uriPath is the path of the resource URI. The body contains the bytes of the HTTP request body.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

top
SendReqBinaryBodyAsync (1)
function CkRest_SendReqBinaryBodyAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    body: HCkByteData): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqBinaryBody method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
SendReqFormUrlEncoded
function CkRest_SendReqFormUrlEncoded(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Sends an application/x-www-form-urlencoded HTTP request where the body is composed of the URL encoded query params. The httpVerb is the HTTP verb (also known as the HTTP method), such as "POST". The uriPath is the path of the resource URI. If the Content-Type header was set, it is ignored and instead the Content-Type of the request will be "application/x-www-form-urlencoded".

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

top
SendReqFormUrlEncodedAsync (1)
function CkRest_SendReqFormUrlEncodedAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqFormUrlEncoded method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
SendReqMultipart
function CkRest_SendReqMultipart(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Sends a multipart REST request. The httpVerb is the HTTP verb (also known as the HTTP method), such as "GET". The uriPath is the path of the resource URI.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

top
SendReqMultipartAsync (1)
function CkRest_SendReqMultipartAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqMultipart method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
SendReqNoBody
function CkRest_SendReqNoBody(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Sends a REST request that cotnains no body. The httpVerb is the HTTP verb (also known as the HTTP method), such as "GET". The uriPath is the path of the resource URI.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

top
SendReqNoBodyAsync (1)
function CkRest_SendReqNoBodyAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqNoBody method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
SendReqSb
function CkRest_SendReqSb(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodySb: HCkStringBuilder): wordbool; stdcall;
Introduced in version 9.5.0.62

Sends a REST request that cotnains a text body, such as XML or JSON. The httpVerb is the HTTP verb (also known as the HTTP method), such as "PUT". The uriPath is the path of the resource URI. The bodySb contains the text of the HTTP request body.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

top
SendReqSbAsync (1)
function CkRest_SendReqSbAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodySb: HCkStringBuilder): HCkTask; stdcall;
Introduced in version 9.5.0.62

Creates an asynchronous task to call the SendReqSb method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
SendReqStreamBody
function CkRest_SendReqStreamBody(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    stream: HCkStream): wordbool; stdcall;
Introduced in version 9.5.0.58

Sends a REST request that cotnains a binary or text body that is obtained by reading from the stream. The httpVerb is the HTTP verb (also known as the HTTP method), such as "PUT". The uriPath is the path of the resource URI.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

More Information and Examples
top
SendReqStreamBodyAsync (1)
function CkRest_SendReqStreamBodyAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    stream: HCkStream): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqStreamBody method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
SendReqStringBody
function CkRest_SendReqStringBody(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodyText: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Sends a REST request that cotnains a text body, such as XML or JSON. The httpVerb is the HTTP verb (also known as the HTTP method), such as "PUT". The uriPath is the path of the resource URI. The bodyText contains the text of the HTTP request body.

IMPORTANT: The uriPath argument should be just the path part of the URL. It is NOT the full URL. If your URL is "https://www.example.com/something/123?xyz=1", then the uriPath is "/something/123?xyz=1".

Returns True for success, False for failure.

More Information and Examples
top
SendReqStringBodyAsync (1)
function CkRest_SendReqStringBodyAsync(objHandle: HCkRest;
    httpVerb: PWideChar;
    uriPath: PWideChar;
    bodyText: PWideChar): HCkTask; stdcall;
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqStringBody method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
SetAuthAws
function CkRest_SetAuthAws(objHandle: HCkRest;
    authProvider: HCkAuthAws): wordbool; stdcall;
Introduced in version 9.5.0.58

Sets the authorization service provider for Amazon AWS REST requests. An application that sets an AWS authentication provider need not explicitly set the Authorization property. Each REST request is automatically signed and authenticated using the authProvider.

Returns True for success, False for failure.

More Information and Examples
top
SetAuthAzureSas
function CkRest_SetAuthAzureSas(objHandle: HCkRest;
    authProvider: HCkAuthAzureSAS): wordbool; stdcall;
Introduced in version 9.5.0.65

Provides the information for Azure SAS (Shared Access Signature) authorization. Calling this method will cause the "Authorization: SharedAccessSignature ..." header to be automatically added to all requests.

Returns True for success, False for failure.

More Information and Examples
top
SetAuthAzureStorage
function CkRest_SetAuthAzureStorage(objHandle: HCkRest;
    authProvider: HCkAuthAzureStorage): wordbool; stdcall;
Introduced in version 9.5.0.58

Sets the authorization service provider for Azure Storage Service requests.

Returns True for success, False for failure.

top
SetAuthBasic
function CkRest_SetAuthBasic(objHandle: HCkRest;
    username: PWideChar;
    password: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Sets the username and password to be used for Basic authentication. This method should be called when Basic authentication is required. It should only be used with secure SSL/TLS connections. Calling this method will cause the "Authorization: Basic ..." header to be automatically added to all requests. In many cases, a REST API will support Basic authentication where the username is a client ID or account ID, and the password is a client secret or token.

Returns True for success, False for failure.

More Information and Examples
top
SetAuthBasicSecure
function CkRest_SetAuthBasicSecure(objHandle: HCkRest;
    username: HCkSecureString;
    password: HCkSecureString): wordbool; stdcall;
Introduced in version 9.5.0.71

The same as SetAuthBasic, but provides a more secure means for passing the arguments as secure string objects.

Returns True for success, False for failure.

More Information and Examples
top
SetAuthGoogle
function CkRest_SetAuthGoogle(objHandle: HCkRest;
    authProvider: HCkAuthGoogle): wordbool; stdcall;
Introduced in version 9.5.0.58

Sets the authorization service provider for Google API requests.

Returns True for success, False for failure.

top
SetAuthOAuth1
function CkRest_SetAuthOAuth1(objHandle: HCkRest;
    authProvider: HCkOAuth1;
    useQueryParams: wordbool): wordbool; stdcall;
Introduced in version 9.5.0.58

Sets the authentication provider for REST API requests needing OAuth 1.0 (and OAuth 1.0a) authentication. If useQueryParams is True, then the OAuth1 authentication information and signature is passed in query parameters. Otherwise it is passed in an Authorization header.

Returns True for success, False for failure.

top
SetAuthOAuth2
function CkRest_SetAuthOAuth2(objHandle: HCkRest;
    authProvider: HCkOAuth2): wordbool; stdcall;
Introduced in version 9.5.0.59

Causes the "Authorization: Bearer <access_token>" header to be added to each request. The authProvider should have been loaded with an OAuth2 access token, which is JSON that looks similar to this:

{
  "access_token": "...",
  "refresh_token": "...",
  "expires_in": 14400,
  "scope": "...",
  "token_type": "bearer",
  "expires_on": "1611099058"
}

Your access token may contain different JSON members, but it should contain the two required members "access_token" and "token_type". The "token_type" should be "bearer" (case-insensitive).

Note: It is also possible to manually add the Authorization header in the same way as any other header by calling the AddHeader method. If the Authorization header is added via AddHeader, then don't use this method.

Returns True for success, False for failure.

top
SetMultipartBodyBd
function CkRest_SetMultipartBodyBd(objHandle: HCkRest;
    bodyData: HCkBinData): wordbool; stdcall;
Introduced in version 9.5.0.62

Only used for multipart requests. Sets the binary content of the multipart body indicated by the PartSelector.

Returns True for success, False for failure.

More Information and Examples
top
SetMultipartBodyBinary
function CkRest_SetMultipartBodyBinary(objHandle: HCkRest;
    bodyData: HCkByteData): wordbool; stdcall;
Introduced in version 9.5.0.58

Only used for multipart requests. Sets the binary content of the multipart body indicated by the PartSelector.

Returns True for success, False for failure.

top
SetMultipartBodySb
function CkRest_SetMultipartBodySb(objHandle: HCkRest;
    bodySb: HCkStringBuilder): wordbool; stdcall;
Introduced in version 9.5.0.62

Only used for multipart requests. Sets the text content of the multipart body indicated by the PartSelector.

Returns True for success, False for failure.

More Information and Examples
top
SetMultipartBodyStream
function CkRest_SetMultipartBodyStream(objHandle: HCkRest;
    stream: HCkStream): wordbool; stdcall;
Introduced in version 9.5.0.58

Only used for multipart requests. Sets the stream source of the multipart body indicated by the PartSelector.

Returns True for success, False for failure.

More Information and Examples
top
SetMultipartBodyString
function CkRest_SetMultipartBodyString(objHandle: HCkRest;
    bodyText: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Only used for multipart requests. Sets the text content of the multipart body indicated by the PartSelector.

Returns True for success, False for failure.

top
SetResponseBodyStream
function CkRest_SetResponseBodyStream(objHandle: HCkRest;
    expectedStatus: Integer;
    autoSetStreamCharset: wordbool;
    responseStream: HCkStream): wordbool; stdcall;
Introduced in version 9.5.0.58

Only applies to the Full* methods, such as FullRequestNoBody, FullRequestBinary, FullRequestStream, etc. When set, the response body is streamed directly to responseStream, if (and only if) the HTTP response status code equals expectedStatus.

If the response body was streamed to responseStream, then the string return value of the Full* method instead becomes "OK" for success. If an attempt was made to stream the response body but it failed, then "FAIL" is returned. If the response body was not streamed because the response status code was not equal to expectedStatus, then the returned string contains the server's error response.

If autoSetStreamCharset is True, then the expectedStatus's StringCharset property will automatically get set based on the charset, if any, indicated in the response header. If the response is binary, then autoSetStreamCharset is ignored.

Starting in v9.5.0.75, the expectedStatus may be passed as a negative number to specify a range of expected (success) status codes. For example:

  • -200: Allow status codes 200 - 299
  • -210: Allow status codes 210 - 219
  • -220: Allow status codes 220 - 229
  • etc.

Returns True for success, False for failure.

top
UseConnection
function CkRest_UseConnection(objHandle: HCkRest;
    connection: HCkSocket;
    autoReconnect: wordbool): wordbool; stdcall;
Introduced in version 9.5.0.58

Sets the connection to be used for sending the REST request. The connection should be an already-connected socket. It may be a TLS connection, an unencrypted connection, through an HTTP proxy, a SOCKS proxy, or even through SSH tunnels. All of the connection related functionality is handled by the Chilkat Socket API.

The autoReconnect indicates whether connection should automatically be established as needed for subsequent REST requests.

Important: The UseConnection method is provided as a means for handling more complicated connections -- such as connections through proxies, tunnels, etc. If your application is connecting directly to the HTTP server, then simply call this class's Connect method.

Returns True for success, False for failure.

top

Events

Chilkat supports event callbacks for the Delphi DLL starting in version 9.5.0.82.

AbortCheck
function MyAbortCheck(): Integer; cdecl;
Introduced in version 9.5.0.82

Provides the opportunity for a method call to be aborted. The AbortCheck event is fired periodically based on the value of the HeartbeatMs property. If HeartbeatMs is 0, then no AbortCheck events will fire. As an example, to fire 5 AbortCheck events per second, set the HeartbeatMs property equal to 200. Return True to abort; return False to continue (not abort)

More Information and Examples
top
PercentDone
function MyPercentDone(pctDone: Integer): Integer; cdecl;
Introduced in version 9.5.0.82

Provides the percentage completed for any method that involves network communications or time-consuming processing (assuming it is a method where a percentage completion can be measured). This event is only fired when it is possible to know a percentage completion, and when it makes sense to express the operation as a percentage completed. The pctDone argument will have a value from 1 to 100. For operations (Chilkat method calls) that complete very quickly, the number of PercentDone callbacks will vary, but the final callback should have a value of 100. For long running operations, no more than one callback per percentage point will occur (for example: 1, 2, 3, ... 98, 99, 100).

The PercentDone callback counts as an AbortCheck event. For method calls that complete quickly such that PercentDone events fire, it may be that AbortCheck events don't fire because the opportunity to abort is already provided in the PercentDone callback. For time consuming operations, where the amount of time between PercentDone callbacks are long, AbortCheck callbacks may be used to allow for the operation to be aborted in a more responsive manner.

Return True to abort; return False to continue (not abort)

More Information and Examples
top
ProgressInfo
procedure MyProgressInfo(name: PWideChar; value: PWideChar) cdecl;
Introduced in version 9.5.0.82

A general name/value event that provides information about what is happening during a method call. To find out what information is available, write code to handle this event and log the name/value pairs. Most are self-explanatory.

More Information and Examples
top
TaskCompleted
procedure MyTaskCompleted(task: HCkTask) cdecl;
Introduced in version 9.5.0.82

Called in the background thread when an asynchronous task completes.

top