Rest C# Reference Documentation

Rest

Current Version: 11.5.0

Chilkat.Rest

Build, send, authenticate, stream, and inspect REST API requests with precise control.

Chilkat.Rest is a flexible REST client class for applications that need detailed control over request construction, connection reuse, authentication, headers, query parameters, multipart bodies, streaming uploads and downloads, response parsing, and low-level diagnostics. It is especially useful for APIs where the application must carefully manage provider-specific signing, request paths, body formats, and server responses.

Precise request construction

Build REST requests with explicit paths, headers, query parameters, request bodies, content types, and HTTP methods.

Connection reuse

Connect once and send multiple requests over the same underlying connection when appropriate.

Authentication support

Work with bearer tokens, OAuth2, AWS-style signing, Azure and Google auth helpers, and other service-specific authentication patterns.

Request bodies and multipart

Send JSON, XML, text, binary data, form parameters, multipart requests, streams, and file-based request bodies.

Response handling

Read response bodies as strings, bytes, streams, JSON, XML, or StringBuilder content, and inspect status codes and headers.

Diagnostics and debugging

Use detailed error text, raw request generation, response headers, connection state, and verbose diagnostics to troubleshoot API behavior.

Choosing the right class: Use Chilkat.Rest when you want fine-grained control over the connection and request construction. For higher-level HTTP convenience methods that accept full URLs directly, use Chilkat.Http. For advanced socket routing, create the connection with Chilkat.Socket and pass it to UseConnection.
Stateful request configuration: Request headers, ordinary query parameters, path substitutions, multipart parts, and authentication settings remain associated with the Rest object until they are replaced or cleared. When reusing an object for unrelated requests, call the applicable Clear* methods rather than assuming request state is automatically reset.
Low-level response workflow: After a SendReq* call, call ReadResponseHeader and then read the response body exactly once when a body is present. Fully consume the body before sending another request on the same connection. A HEAD response has no body; a 204 No Content response is represented by an empty body.
Redirects and cookies: The Rest class exposes redirect and response-header information but does not automatically follow redirects or maintain a cookie jar. Applications should process Location and Set-Cookie values explicitly when needed.

Object Creation

Chilkat.Rest obj = new Chilkat.Rest();

Properties

AllowHeaderFolding
public bool AllowHeaderFolding {get; set; }
Introduced in version 9.5.0.63

Controls whether long request-header fields may be folded onto continuation lines. The default is false. When set to false, each request header is emitted on a single physical line.

Modern HTTP compatibility: Obsolete HTTP line folding is rejected by some servers and signing systems. Set this property to false when the service requires unfolded header lines, as is common for canonicalized request signatures.

top
AllowHeaderQB
public bool AllowHeaderQB {get; set; }
Introduced in version 9.5.0.59

Controls whether non-ASCII request-header values may be converted to RFC 2047 encoded-word form using Q or Base64 encoding. The default is true.

Encoded words have forms such as =?utf-8?Q?...?= and =?utf-8?B?...?=. When this property is false, Chilkat does not apply this conversion.

Compatibility feature: RFC 2047 encoded words originated in Internet message headers. Use this behavior only when the target HTTP service expects it; many APIs instead require ASCII header values or a service-specific encoding.

top
Authorization
public string Authorization {get; set; }
Introduced in version 9.5.0.58

Gets or sets the value sent in the HTTP Authorization request header. Supply only the field value, such as Bearer eyJ..., not the text Authorization:.

Authentication helpers: For generated authentication, prefer the appropriate SetAuth* method. A configured authentication provider may generate or replace the Authorization header when the request is sent.
Provider precedence: When a SetAuth* provider is active, its generated Authorization header takes precedence over this property and over a manually added Authorization header. ClearAuth clears both the provider and this value; clearing top-level headers also clears this property.

top
ConnectFailReason
public int ConnectFailReason {get; }
Introduced in version 9.5.0.58

After Connect fails, returns a code identifying the connection stage or TLS handshake stage that failed.

CodeMeaning
0Success
1Empty hostname
2DNS lookup failed
3DNS timeout
4Aborted by the application
5Internal failure
6Connection timed out
7Connection rejected or otherwise failed
99Chilkat is not unlocked or the trial expired

TLS-related codes:

CodeMeaning
100TLS internal error
101Failed to send ClientHello
102Unexpected handshake message
103Failed to read ServerHello
104No server certificate
105Unexpected TLS protocol version
106Server certificate verification failed
107Unacceptable TLS protocol version
109Failed to read handshake messages
110Failed to send the client-certificate handshake message
111Failed to send ClientKeyExchange
112Client certificate private key is inaccessible
113Failed to send CertificateVerify
114Failed to send ChangeCipherSpec
115Failed to send Finished
116The server Finished message is invalid
Detailed diagnostics: Use the code as a category and inspect LastErrorText for the full failure context.
Reset after success: A successful Connect resets this property to 0. HTTP response properties are separate and are not cleared by a later failed connection attempt.

top
ConnectTimeoutMs
public int ConnectTimeoutMs {get; set; }
Introduced in version 9.5.0.71

Gets or sets the maximum number of milliseconds to wait for the remote server to accept the TCP connection. This timeout covers connection establishment, not the later sending or receiving of HTTP data.

Related timeout: Use IdleTimeoutMs to control how long an established operation may remain without send or receive progress.

The default is 30000 milliseconds.

top
DebugLogFilePath
public string DebugLogFilePath {get; set; }

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

top
DebugMode
public bool DebugMode {get; set; }
Introduced in version 9.5.0.77

When true, calls to the Send* and FullRequest* methods compose the complete request but do not transmit it. Retrieve the generated request with GetLastDebugRequest. The default is false.

Safe request inspection: This is useful for validating signing, headers, query strings, multipart formatting, and body encoding without contacting the server. The captured request may contain secrets.

In debug mode, a composed full-request call reports a synthetic successful result with ResponseStatusCode equal to 201, ResponseStatusText equal to OK, and no actual response header or response body.

top
EnableSecrets
public bool EnableSecrets {get; set; }
Introduced in version 11.5.0

Controls automatic resolution of credentials from operating-system secure storage. The default is false.

When set to true, supported credential inputs may contain a secret specification beginning with !! instead of a literal secret. Chilkat resolves the specification from Windows Credential Manager on Windows or Apple Keychain on macOS.

The specification format is:

!![appName|]service[|domain]|username

For this class, secret specifications apply to the username and password supplied to SetAuthBasic.

Why use secret resolution: It avoids embedding long-lived credentials directly in source code, configuration files, command lines, or logs. The requested secret must already exist in the platform credential store.

More Information and Examples
top
HeartbeatMs
public int HeartbeatMs {get; set; }
Introduced in version 9.5.0.58

Controls the interval, in milliseconds, between AbortCheck event callbacks during supported long-running operations. The default is 0, which disables periodic AbortCheck callbacks.

Choosing an interval: A smaller value makes cancellation more responsive but causes callbacks more frequently.

More Information and Examples
top
Host
public string Host {get; set; }
Introduced in version 9.5.0.58

Gets or sets the value of the HTTP Host request header.

Usually automatic: For a normal connection, Chilkat derives the Host header from the server established by Connect or UseConnection. Set this property explicitly only when the request must present a different virtual-host value.

An explicitly assigned value overrides the generated HTTP Host field, but it does not change the TCP/TLS destination established by Connect or UseConnection.

top
IdleTimeoutMs
public int IdleTimeoutMs {get; set; }
Introduced in version 9.5.0.58

Gets or sets the maximum number of milliseconds to wait when a send or receive operation has stopped making progress. The default is 30000 milliseconds.

Not an overall deadline: This is an inactivity timeout. An operation can run longer than this value as long as data continues to be sent or received.

A value of 0 disables the inactivity timeout.

top
LastErrorHtml
public string LastErrorHtml {get; }

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
public string LastErrorText {get; }

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
public string LastErrorXml {get; }

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
public bool LastMethodSuccess {get; set; }

Indicates the success or failure of the most recent method call: true means success, false means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
LastRedirectUrl
public string LastRedirectUrl {get; }
Introduced in version 11.0.0

Returns the redirect target from the most recently received response. The value comes from the response Location header. If the most recent response was not a redirect or did not contain a Location header, this property is empty.

Relative redirects: A Location value may be an absolute URL or a relative reference, depending on the server response.
Redirect handling: The value is the response Location field as received. Rest does not automatically follow the redirect; send a new request explicitly, reconnecting first if the target host changes.

top
LastRequestHeader
public string LastRequestHeader {get; }
Introduced in version 9.5.0.58

Returns the HTTP header fields from the most recently composed request, excluding the request line. The request line is available separately in LastRequestStartLine.

Sensitive data: The header block may contain credentials, bearer tokens, cookies, or signatures. Avoid writing it to logs unless sensitive values are redacted.

A failed Connect does not clear this value. It continues to describe the last request that was composed and sent.

top
LastRequestStartLine
public string LastRequestStartLine {get; }
Introduced in version 9.5.0.58

Returns the request line from the most recently composed request. It contains the HTTP method, request target, and HTTP version, for example:

GET /v1/items?limit=10 HTTP/1.1

A failed Connect does not clear this value. It continues to describe the last request that was composed and sent.

top
NumResponseHeaders
public int NumResponseHeaders {get; }
Introduced in version 9.5.0.58

Returns the number of response header field occurrences. Enumerate them with zero-based indexes using ResponseHdrName and ResponseHdrValue.

A failed Connect does not reset this count; it remains the count for the last received HTTP response.

top
PartSelector
public string PartSelector {get; set; }
Introduced in version 9.5.0.58

Selects the multipart entity or part targeted by multipart-building operations such as AddHeader, RemoveHeader, and the SetMultipartBody* methods.

ValueSelected target
(empty)The top-level request entity
0The top-level request entity
1The first multipart subpart
2The second multipart subpart
1.2The second child within the first subpart
Multipart indexes: PartSelector uses one-based part numbers, unlike most Chilkat indexed accessors. Reset it to the empty string before modifying top-level request headers.

The value 0, like the empty string, selects the top-level request entity. A nonnumeric selector is invalid. A body assignment can create a higher-numbered part even when lower-numbered parts do not yet exist.

top
PercentDoneOnSend
public bool PercentDoneOnSend {get; set; }
Introduced in version 9.5.0.58

Applies to the full-request methods that both upload a request and download a response. It selects which direction is represented by percent-complete events.

  • false (default): progress refers to receiving the response body.
  • true: progress refers to sending the request body.
A known total is required: Percentage can be calculated only when the total byte count is known. For example, a chunked response may not provide a total response length.

top
ResponseHeader
public string ResponseHeader {get; }
Introduced in version 9.5.0.58

Returns the HTTP response header fields from the most recently received response, excluding the status line.

Status line: The numeric status and reason text are available through ResponseStatusCode and ResponseStatusText.

Repeated fields remain separate and in received order. The field-name casing is preserved. A failed Connect does not clear this value; it continues to describe the last received HTTP response.

top
ResponseStatusCode
public int ResponseStatusCode {get; }
Introduced in version 9.5.0.58

Returns the numeric HTTP status code from the most recently received response, such as 200, 404, or 503.

HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.
Last completed exchange: A failed Connect does not clear this property. It continues to report the status of the last HTTP response that was actually received.

top
ResponseStatusText
public string ResponseStatusText {get; }
Introduced in version 9.5.0.58

Returns the reason phrase associated with the most recently received HTTP status code, such as OK or Not Found.

Reason phrases are informational: Applications should make decisions from the numeric status code. A reason phrase may be empty or may vary by server.
Last completed exchange: A failed Connect does not clear this property; it remains associated with the last received HTTP response.

top
StreamNonChunked
public bool StreamNonChunked {get; set; }
Introduced in version 9.5.0.58

Controls whether streaming uploads use a Content-Length header instead of HTTP/1.1 chunked transfer encoding when the total body size is known. The default is true.

When true and the stream length can be determined—for example, a file stream—Chilkat sends a non-chunked request. When false, Chilkat uses Transfer-Encoding: chunked. If the stream length is unknown, chunked transfer may still be required.

Server compatibility: Some HTTP servers and signing schemes require Content-Length and do not accept chunked request bodies; others support either form.

top
UncommonOptions
public string UncommonOptions {get; set; }
Introduced in version 9.5.0.80

Provides opt-in compatibility settings for uncommon requirements. The default is the empty string. Supply one or more comma-separated keywords:

KeywordEffect
AllowDuplicateQueryParamsAllows AddQueryParam to append another parameter having the same name instead of replacing the existing one.
AllowInsecureBasicAuthAllows Basic authentication over a non-TLS remote connection. By default, Basic authentication is allowed only over TLS, an SSH tunnel, or localhost.
DisableTls13Disables TLS 1.3 so negotiation is limited to TLS 1.2 or earlier supported versions.
ProtectFromVpnOn Android, attempts to bypass an installed or active VPN for this connection.
Use sparingly: Leave this property empty unless a documented interoperability requirement calls for one of these options. In particular, AllowInsecureBasicAuth can expose credentials to network observers.

top
VerboseLogging
public bool VerboseLogging {get; set; }

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
public string Version {get; }

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

top

Methods

AddHeader
public bool AddHeader(string name, string value);
Introduced in version 9.5.0.58

Adds an HTTP request header using name as the field name and value as the field value. If a request header with the same name is already present for the selected part, its value is replaced.

HTTP header names: Field names are case-insensitive. Pass only the field name in name—for example, Content-Type—and not the trailing colon. For multipart requests, PartSelector determines whether the header is added to the top-level request or to a MIME part.

Request headers persist across requests until removed or cleared. Adding the same header again replaces its current value.

Multipart selection: Header operations apply to the entity selected by PartSelector. Use an empty selector or 0 for top-level request headers; select a part before adding that part's headers.

Returns true for success, false for failure.

top
AddMwsSignature
public bool AddMwsSignature(string httpVerb, string uriPath, string domain, string mwsSecretKey);
Introduced in version 9.5.0.66

Computes the Amazon Marketplace Web Service (MWS) request signature using the secret key in mwsSecretKey and adds or replaces the Signature query parameter. Call this after all other MWS request parameters have been added.

httpVerb is the HTTP method, uriPath is the MWS resource path, and domain is the request domain. httpVerb and uriPath should match the values used by the request-sending method. The method also adds or replaces the Timestamp parameter using the current system time.

Legacy MWS signing: This method implements Amazon MWS signing and is not a general AWS request signer. For AWS services that use AWS authorization providers, use SetAuthAws.

Returns true for success, false for failure.

top
AddPathParam
public bool AddPathParam(string name, string value);
Introduced in version 9.5.0.70

Adds or replaces a path-substitution parameter. Before a request is sent, occurrences of name in the supplied request path are replaced by value.

For example, setting name to fileId and value to abc123 transforms /drive/v3/files/fileId into /drive/v3/files/abc123.

Placeholders are application-defined: The placeholder syntax is simply the text stored in name; braces are not required unless they are part of the placeholder text you choose.

Matching is case-sensitive and literal. Every occurrence of name is replaced, substitutions are applied in the order they were added, and replacement applies to the entire uriPath string, including any query portion.

Reserved characters: The replacement is not a general path-segment encoder. Spaces are percent-encoded, but reserved URI characters such as /, ?, and # remain delimiters, and existing percent escapes are preserved. Percent-encode reserved characters before calling this method when they are intended to be data.

Path substitutions persist across requests until replaced or removed with ClearAllPathParams.

Returns true for success, false for failure.

top
AddQueryParam
public bool AddQueryParam(string name, string value);
Introduced in version 9.5.0.58

Adds or replaces a query-string parameter using name as the parameter name and value as its value. The stored query parameters are incorporated into the request target when a request is sent.

Duplicate parameter names: By default, adding the same name again replaces the existing value. To retain repeated names such as tag=red&tag=blue, include AllowDuplicateQueryParams in UncommonOptions.
Encoding and lifetime: name and value are unencoded text. Chilkat percent-encodes the parameter name and value when composing the request target. For example, a space becomes %20, a literal plus sign becomes %2B, and a literal percent sign becomes %25. Existing percent escapes supplied to this method are therefore encoded again. Parameters persist across ordinary requests until removed or cleared.

Parameter names are case-sensitive. Adding the same exact name again replaces the existing value unless AllowDuplicateQueryParams is enabled in UncommonOptions.

Returns true for success, false for failure.

top
AddQueryParams
public bool AddQueryParams(string queryString);
Introduced in version 9.5.0.58

Adds multiple query parameters from the query-string text in queryString. Use the form field1=value1&field2=value2&field3=value3.

Encoding responsibility: The values in queryString must already be percent-encoded as required for a URL query string. Do not include a leading ?. For individual name/value pairs, AddQueryParam is usually clearer.

The input is parsed as an already URL-encoded query string and then normalized when the request is composed. A plus sign is interpreted as a space and is emitted as %20; encoded delimiters such as %26 remain data; an item without an equals sign is treated as a parameter with an empty value.

Parameters added by this method persist across ordinary requests. When ARG2 of a request method already contains a query string, those inline parameters appear first, followed by the parameters stored in the Rest object.

Returns true for success, false for failure.

top
AddQueryParamSb
public bool AddQueryParamSb(string name, StringBuilder value);
Introduced in version 9.5.0.62

Adds or replaces a query-string parameter named by name. The parameter value is read from the StringBuilder in value.

Duplicate parameter names: By default, the same name is replaced. Include AllowDuplicateQueryParams in UncommonOptions to retain repeated names.
Encoding and lifetime: name and the text in value are unencoded text. Chilkat percent-encodes the parameter name and value when composing the request target. For example, a space becomes %20, a literal plus sign becomes %2B, and a literal percent sign becomes %25. Existing percent escapes supplied to this method are therefore encoded again. Parameters persist across ordinary requests until removed or cleared.

Parameter names are case-sensitive. Adding the same exact name again replaces the existing value unless AllowDuplicateQueryParams is enabled in UncommonOptions.

Returns true for success, false for failure.

top
ClearAllHeaders
public bool ClearAllHeaders();
Introduced in version 9.5.0.58

Removes all HTTP request headers previously added to this object.

The method clears headers only from the entity selected by PartSelector. Clearing top-level headers also clears the Authorization property. Automatically generated fields such as Host and Content-Length may be added again when the next request is composed.

Returns true for success, false for failure.

top
ClearAllParts
public bool ClearAllParts();
Introduced in version 9.5.0.64

Removes all multipart subparts from the request under construction. This is useful when reusing the same REST object after sending a multipart request.

Scope: This clears multipart parts; it does not by itself clear query parameters, path parameters, authentication settings, or ordinary top-level request headers.

This also resets PartSelector to the empty string and releases the configured multipart bodies and part streams.

Returns true for success, false for failure.

top
ClearAllPathParams
public bool ClearAllPathParams();
Introduced in version 9.5.0.70

Removes all path-substitution parameters previously added with AddPathParam.

After clearing, placeholder text in later request paths is sent unchanged.

Returns true for success, false for failure.

top
ClearAllQueryParams
public bool ClearAllQueryParams();
Introduced in version 9.5.0.58

Removes all query parameters previously added to this object.

This clears the stored query/form parameter collection. It does not remove a query string written directly in the uriPath argument of a request method.

Returns true for success, false for failure.

top
ClearAuth
public bool ClearAuth();
Introduced in version 9.5.0.69

Clears authentication providers and credentials previously configured through this class's SetAuth* methods.

This removes the active authentication provider and clears the manually configured Authorization value.

Returns true for success, false for failure.

top
ClearResponseBodyStream
public void ClearResponseBodyStream();
Introduced in version 9.5.0.58

Clears the response-stream destination previously configured by SetResponseBodyStream. Subsequent full-request methods return or store the response body normally instead of streaming it to that destination.

Clearing the destination does not alter the Stream object itself.

top
Connect
public bool Connect(string hostname, int port, bool tls, bool autoReconnect);
Introduced in version 9.5.0.58

Establishes the initial TCP connection to the REST server. hostname is a DNS hostname or an IPv4/IPv6 address, port is the server port, and tls specifies whether the connection uses TLS. Common combinations are port 80 with tls set to false, and port 443 with tls set to true.

If autoReconnect is true, subsequent requests may automatically reconnect when the existing connection is no longer usable. If autoReconnect is false, a lost connection causes the request to fail until the application explicitly reconnects.

Hostname only: hostname is not a URL. For https://api.example.com/v1/items, pass api.example.com. The request path is supplied separately to the request method.
Advanced connections: Connect is intended for a direct connection. For HTTP or SOCKS proxies, SSH tunneling, client certificates, custom socket routing, or other advanced connection setup, establish a connected Socket and pass it to UseConnection.
Reconnect behavior: When autoReconnect is true, Chilkat can establish a new connection before a later request after the previous connection has closed. This option should not be interpreted as a promise to replay a request that failed after transmission began.
Result-state behavior: A successful connection resets ConnectFailReason to 0. A failed Connect does not clear the HTTP response and last-request properties from an earlier completed exchange; those properties continue to describe the last HTTP request/response, not the failed connection attempt.

Returns true for success, false for failure.

top
ConnectAsync (C#) (PowerShell)
public Task ConnectAsync(string hostname, int port, bool tls, bool autoReconnect);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the Connect method with the arguments provided.

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 null on failure

top
Disconnect
public bool Disconnect(int maxWaitMs);
Introduced in version 9.5.0.58

Closes the current HTTP connection, if one is open. maxWaitMs is the maximum number of milliseconds to wait while attempting a clean shutdown.

Tunneled connections: When the REST connection uses an SSH tunnel, this closes the logical channel used by REST. It does not close the underlying SSH session itself.
Socket supplied by UseConnection: When the transport was supplied through UseConnection, calling Disconnect also disconnects that Socket. If automatic reconnection was enabled, a later request may reconnect it.

Returns true for success, false for failure.

top
DisconnectAsync (C#) (PowerShell)
public Task DisconnectAsync(int maxWaitMs);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the Disconnect method with the arguments provided.

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 null on failure

top
FullRequestBd
public bool FullRequestBd(string httpVerb, string uriPath, BinData binData, StringBuilder responseBody);
Introduced in version 9.5.0.64

Sends a complete request whose binary body is read from the BinData in binData. The text response body replaces the existing contents of the StringBuilder in responseBody.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.

responseBody is cleared and replaced with the textual response body.

Returns true for success, false for failure.

top
FullRequestBdAsync (C#) (PowerShell)
public Task FullRequestBdAsync(string httpVerb, string uriPath, BinData binData, StringBuilder responseBody);
Introduced in version 9.5.0.64

Creates an asynchronous task to call the FullRequestBd method with the arguments provided.

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 null on failure

top
FullRequestBinary
public string FullRequestBinary(string httpVerb, string uriPath, byte[] bodyBytes);
Introduced in version 9.5.0.58

Sends a complete request whose body is the binary data in bodyBytes. The response body is read as text and returned.

This convenience method performs the equivalent of SendReqBinaryBody, ReadResponseHeader, and ReadRespBodyString in sequence.

For full-request methods, PercentDoneOnSend selects whether percent-complete events refer to sending the request body or receiving the response body.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.
Preferred binary API: For new code, FullRequestBd uses BinData and avoids language-specific byte-array limitations.

Returns null on failure

top
FullRequestBinaryAsync (C#) (PowerShell)
public Task FullRequestBinaryAsync(string httpVerb, string uriPath, byte[] bodyBytes);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestBinary method with the arguments provided.

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 null on failure

top
FullRequestFormUrlEncoded
public string FullRequestFormUrlEncoded(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Sends a complete application/x-www-form-urlencoded request. The form body is built from the parameters previously added with AddQueryParam or AddQueryParams. The request Content-Type is set to application/x-www-form-urlencoded. The response body is read as text and returned.

This convenience method performs the equivalent of SendReqFormUrlEncoded, ReadResponseHeader, and ReadRespBodyString in sequence.

For full-request methods, PercentDoneOnSend selects whether percent-complete events refer to sending the request body or receiving the response body.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.

Parameters written directly in uriPath remain in the URL query string. Parameters stored through AddQueryParam, AddQueryParamSb, or AddQueryParams are encoded into the form body. After the form request is sent, this stored parameter collection is cleared.

Persistent Content-Type: The method sets the top-level Content-Type to application/x-www-form-urlencoded. That request-header value remains configured for later requests until it is replaced or cleared.

Returns null on failure

top
FullRequestFormUrlEncodedAsync (C#) (PowerShell)
public Task FullRequestFormUrlEncodedAsync(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestFormUrlEncoded method with the arguments provided.

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 null on failure

top
FullRequestMultipart
public string FullRequestMultipart(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Sends a complete multipart request using the parts and part headers configured through PartSelector, AddHeader, and the multipart-body methods. The response body is read as text and returned.

This convenience method performs the equivalent of SendReqMultipart, ReadResponseHeader, and ReadRespBodyString in sequence.

For full-request methods, PercentDoneOnSend selects whether percent-complete events refer to sending the request body or receiving the response body.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.
Multipart state: Assigning a body to a selected part creates that part. Parts may be created out of numeric order, persist across multipart requests, and retain the generated boundary while the multipart structure remains configured. The default top-level media type is multipart/form-data.

The request fails if no multipart subparts are configured.

Returns null on failure

top
FullRequestMultipartAsync (C#) (PowerShell)
public Task FullRequestMultipartAsync(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestMultipart method with the arguments provided.

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 null on failure

top
FullRequestNoBody
public string FullRequestNoBody(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Sends a complete request with no request body. The response body is read as text and returned.

This convenience method performs the equivalent of SendReqNoBody, ReadResponseHeader, and ReadRespBodyString in sequence.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.

Returns null on failure

top
FullRequestNoBodyAsync (C#) (PowerShell)
public Task FullRequestNoBodyAsync(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestNoBody method with the arguments provided.

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 null on failure

top
FullRequestNoBodyBd
public bool FullRequestNoBodyBd(string httpVerb, string uriPath, BinData binData);
Introduced in version 9.5.0.64

Sends a complete request without a request body and stores the binary response body in the BinData in binData, replacing its previous contents.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.

binData is cleared and replaced with the binary response body.

Returns true for success, false for failure.

top
FullRequestNoBodyBdAsync (C#) (PowerShell)
public Task FullRequestNoBodyBdAsync(string httpVerb, string uriPath, BinData binData);
Introduced in version 9.5.0.64

Creates an asynchronous task to call the FullRequestNoBodyBd method with the arguments provided.

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 null on failure

top
FullRequestNoBodySb
public bool FullRequestNoBodySb(string httpVerb, string uriPath, StringBuilder sb);
Introduced in version 9.5.0.64

Sends a complete request without a request body and stores the text response body in the StringBuilder in sb, replacing its previous contents.

This is the StringBuilder form of FullRequestNoBody.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.

sb is cleared and replaced with the textual response body.

Returns true for success, false for failure.

top
FullRequestNoBodySbAsync (C#) (PowerShell)
public Task FullRequestNoBodySbAsync(string httpVerb, string uriPath, StringBuilder sb);
Introduced in version 9.5.0.64

Creates an asynchronous task to call the FullRequestNoBodySb method with the arguments provided.

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 null on failure

top
FullRequestSb
public bool FullRequestSb(string httpVerb, string uriPath, StringBuilder requestBody, StringBuilder responseBody);
Introduced in version 9.5.0.62

Sends a complete request whose text body is read from the StringBuilder in requestBody. The text response body replaces the existing contents of the StringBuilder in responseBody.

This is the StringBuilder form of FullRequestString.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.
Text encoding and Content-Type: Unicode text is encoded as UTF-8. Generic string-body methods do not automatically add a Content-Type header; add the media type required by the API, such as application/json; charset=utf-8.

responseBody is cleared and replaced with the response body.

Returns true for success, false for failure.

top
FullRequestSbAsync (C#) (PowerShell)
public Task FullRequestSbAsync(string httpVerb, string uriPath, StringBuilder requestBody, StringBuilder responseBody);
Introduced in version 9.5.0.62

Creates an asynchronous task to call the FullRequestSb method with the arguments provided.

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 null on failure

top
FullRequestStream
public string FullRequestStream(string httpVerb, string uriPath, Stream stream);
Introduced in version 9.5.0.58

Sends a complete request whose body is read from the Stream in stream. Streaming is appropriate for large uploads because the entire request body need not be held in memory. The response body is read as text and returned.

This convenience method performs the equivalent of SendReqStreamBody, ReadResponseHeader, and ReadRespBodyString in sequence.

For full-request methods, PercentDoneOnSend selects whether percent-complete events refer to sending the request body or receiving the response body.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.
Stream position: The stream is read from its current position and is left consumed. Reusing the same stream without resetting its source or position sends only the unread remainder, which may be zero bytes.

Returns null on failure

top
FullRequestStreamAsync (C#) (PowerShell)
public Task FullRequestStreamAsync(string httpVerb, string uriPath, Stream stream);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestStream method with the arguments provided.

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 null on failure

top
FullRequestString
public string FullRequestString(string httpVerb, string uriPath, string bodyText);
Introduced in version 9.5.0.58

Sends a complete request whose text body is supplied in bodyText, such as JSON, XML, or plain text. The response body is read as text and returned.

This convenience method performs the equivalent of SendReqStringBody, ReadResponseHeader, and ReadRespBodyString in sequence.

For full-request methods, PercentDoneOnSend selects whether percent-complete events refer to sending the request body or receiving the response body.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
HTTP status versus method success: Receiving an HTTP error status such as 400 or 404 is still a completed HTTP exchange. Inspect ResponseStatusCode and the response body to determine the API-level result.
Text encoding and Content-Type: Unicode text is encoded as UTF-8. Generic string-body methods do not automatically add a Content-Type header; add the media type required by the API, such as application/json; charset=utf-8.

Returns null on failure

top
FullRequestStringAsync (C#) (PowerShell)
public Task FullRequestStringAsync(string httpVerb, string uriPath, string bodyText);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the FullRequestString method with the arguments provided.

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 null on failure

top
GetLastDebugRequest
public bool GetLastDebugRequest(BinData bd);
Introduced in version 9.5.0.77

Copies the fully composed HTTP request generated while DebugMode was true into the BinData in bd. The captured data includes the request line, headers, and body that would have been sent.

Diagnostic use: Debug mode does not transmit the request. Treat captured requests as sensitive because they may contain authorization headers, cookies, tokens, or request-body credentials.

bd is cleared and replaced. The captured bytes are the complete composed HTTP/1.1 request, including chunk framing when a streaming request uses Transfer-Encoding: chunked.

Returns true for success, false for failure.

top
GetLastJsonData
public void GetLastJsonData(JsonObject json);
Introduced in version 11.0.0

Copies operation-specific diagnostic or result information from the most recently completed method into the JsonObject in json. Many methods do not produce additional JSON details, in which case the object is empty.

Read immediately: Call this immediately after the operation of interest because a later method call may replace the stored JSON data.
top
LoadTaskCaller
public bool LoadTaskCaller(Task task);
Introduced in version 9.5.0.80

Loads into this object the caller associated with the Task in task. task must be a task returned by an asynchronous method of this class.

Async task relationship: This method recovers the originating REST caller state from a task; it does not load arbitrary task data.

Returns true for success, false for failure.

top
ReadRespBd
public bool ReadRespBd(BinData responseBody);
Introduced in version 9.5.0.62

Reads the response body as raw bytes into the BinData in responseBody, replacing its previous contents. Call this after ReadResponseHeader.

Use for binary content: Typical examples include images, archives, PDFs, encrypted data, and arbitrary file downloads.
Read once: A response body may be consumed by only one body-reading method. A second attempt fails immediately. Fully consume the body before sending another request on the same connection; otherwise unread bytes can prevent the next response header from being parsed correctly.
Responses without a body: Do not call a body-reading method for a HEAD response. A 204 No Content response is handled as a successful empty body.

Returns true for success, false for failure.

top
ReadRespBdAsync (C#) (PowerShell)
public Task ReadRespBdAsync(BinData responseBody);
Introduced in version 9.5.0.62

Creates an asynchronous task to call the ReadRespBd method with the arguments provided.

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 null on failure

top
ReadRespBodyBinary
public byte[] ReadRespBodyBinary();
Introduced in version 9.5.0.58

Reads the response body as raw bytes. Call this only after ReadResponseHeader has returned the response status code.

Choosing a response type: Use this method for images, archives, encrypted content, and other non-text data. For new code, ReadRespBd stores the bytes in BinData.
Read once: A response body may be consumed by only one body-reading method. A second attempt fails immediately. Fully consume the body before sending another request on the same connection; otherwise unread bytes can prevent the next response header from being parsed correctly.
Responses without a body: Do not call a body-reading method for a HEAD response. A 204 No Content response is handled as a successful empty body.

Returns an empty byte array on failure

top
ReadRespBodyBinaryAsync (C#) (PowerShell)
public Task ReadRespBodyBinaryAsync();
Introduced in version 9.5.0.58

Creates an asynchronous task to call the ReadRespBodyBinary method with the arguments provided.

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 null on failure

top
ReadRespBodyStream
public bool ReadRespBodyStream(Stream stream, bool autoSetStreamCharset);
Introduced in version 9.5.0.58

Reads the response body into the Stream supplied in stream. Call this after ReadResponseHeader.

If autoSetStreamCharset is true and the response is textual, the stream's StringCharset is set from the charset parameter in the response Content-Type header when one is present. autoSetStreamCharset has no effect for binary responses.

Large downloads: A stream can write directly to a file or another destination, avoiding the need to buffer the entire response body in memory.
Read once: A response body may be consumed by only one body-reading method. A second attempt fails immediately. Fully consume the body before sending another request on the same connection; otherwise unread bytes can prevent the next response header from being parsed correctly.
Responses without a body: Do not call a body-reading method for a HEAD response. A 204 No Content response is handled as a successful empty body.

Returns true for success, false for failure.

top
ReadRespBodyStreamAsync (C#) (PowerShell)
public Task ReadRespBodyStreamAsync(Stream stream, bool autoSetStreamCharset);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the ReadRespBodyStream method with the arguments provided.

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 null on failure

top
ReadRespBodyString
public string ReadRespBodyString();
Introduced in version 9.5.0.58

Reads the response body as text and returns it. Call this only after ReadResponseHeader has returned the response status code.

Text versus binary: Use this method for JSON, XML, HTML, and other textual responses. Use ReadRespBd or ReadRespBodyStream for binary or very large content.
Read once: A response body may be consumed by only one body-reading method. A second attempt fails immediately. Fully consume the body before sending another request on the same connection; otherwise unread bytes can prevent the next response header from being parsed correctly.
Responses without a body: Do not call a body-reading method for a HEAD response. A 204 No Content response is handled as a successful empty body.

Returns null on failure

top
ReadRespBodyStringAsync (C#) (PowerShell)
public Task ReadRespBodyStringAsync();
Introduced in version 9.5.0.58

Creates an asynchronous task to call the ReadRespBodyString method with the arguments provided.

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 null on failure

top
ReadRespChunkBd
public int ReadRespChunkBd(int minSize, BinData bd);
Introduced in version 10.1.0

After ReadResponseHeader has been called, reads the next chunk of the response body and appends the received bytes to the BinData in bd. The call waits until at least minSize bytes are available, unless the response ends first. The final chunk may contain fewer than minSize bytes, including zero bytes.

Return valueMeaning
-1The read failed; inspect LastErrorText.
0The remaining response bytes were returned and the response body is complete.
1A chunk was returned and more response bytes remain.
Incremental processing: This method is useful when the application wants to process a long response progressively rather than buffer it all at once.

Returns true for success, false for failure.

top
ReadRespChunkBdAsync (C#) (PowerShell)
public Task ReadRespChunkBdAsync(int minSize, BinData bd);
Introduced in version 10.1.0

Creates an asynchronous task to call the ReadRespChunkBd method with the arguments provided.

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 null on failure

top
ReadResponseHeader
public int ReadResponseHeader();
Introduced in version 9.5.0.58

Reads the HTTP response status line and header fields. The returned integer is the HTTP status code, such as 200, 404, or 500. A return value of -1 means that no HTTP response was received because a transport or protocol error occurred.

After this method returns a status code, inspect ResponseHeader, ResponseStatusCode, ResponseStatusText, and the response-header access methods. If the response has a body, read it with ReadRespBodyString, ReadRespBd, ReadRespBodyStream, or another appropriate body-reading method.

Do not infer body presence from the request method alone: Whether a response body is present depends on the response status, request method, and response headers. For example, a GET commonly has a response body, while HEAD does not.
Read once: A response body may be consumed by only one body-reading method. A second attempt fails immediately. Fully consume the body before sending another request on the same connection; otherwise unread bytes can prevent the next response header from being parsed correctly.
Responses without a body: Do not call a body-reading method for a HEAD response. A 204 No Content response is handled as a successful empty body.
top
ReadResponseHeaderAsync (C#) (PowerShell)
public Task ReadResponseHeaderAsync();
Introduced in version 9.5.0.58

Creates an asynchronous task to call the ReadResponseHeader method with the arguments provided.

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 null on failure

top
ReadRespSb
public bool ReadRespSb(StringBuilder responseBody);
Introduced in version 9.5.0.62

Reads the response body as text into the StringBuilder in responseBody, replacing its previous contents. Call this after ReadResponseHeader.

Read once: A response body may be consumed by only one body-reading method. A second attempt fails immediately. Fully consume the body before sending another request on the same connection; otherwise unread bytes can prevent the next response header from being parsed correctly.
Responses without a body: Do not call a body-reading method for a HEAD response. A 204 No Content response is handled as a successful empty body.

Returns true for success, false for failure.

top
ReadRespSbAsync (C#) (PowerShell)
public Task ReadRespSbAsync(StringBuilder responseBody);
Introduced in version 9.5.0.62

Creates an asynchronous task to call the ReadRespSb method with the arguments provided.

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 null on failure

top
RemoveHeader
public bool RemoveHeader(string name);
Introduced in version 9.5.0.58

Removes all request headers named by name from the request level selected by PartSelector.

Header-name matching is case-insensitive, and all matching occurrences are removed.

Returns true for success, false for failure.

top
RemoveQueryParam
public bool RemoveQueryParam(string name);
Introduced in version 9.5.0.58

Removes all query parameters whose name matches name.

Parameter-name matching is case-sensitive. All parameters having the exact name are removed. A true return value indicates that the operation completed successfully; it does not guarantee that a matching parameter existed.

Returns true for success, false for failure.

top
ResponseHdrByName
public string ResponseHdrByName(string name);
Introduced in version 9.5.0.58

Returns the value of the response header field named by name. HTTP header field names are case-insensitive.

Repeated response headers: When the response can contain repeated fields, use NumResponseHeaders, ResponseHdrName, and ResponseHdrValue to enumerate every field occurrence.

If the response contains the same field more than once, this method returns the first matching value. Enumerate the header collection to obtain all occurrences, especially for fields such as Set-Cookie.

Returns null on failure

top
ResponseHdrName
public string ResponseHdrName(int index);
Introduced in version 9.5.0.58

Returns the field name of the response header at zero-based index index. Valid indexes range from 0 through NumResponseHeaders minus one.

Enumeration preserves the response-field order and the field-name casing received from the server. Repeated fields occupy separate indexes.

Returns null on failure

top
ResponseHdrValue
public string ResponseHdrValue(int index);
Introduced in version 9.5.0.58

Returns the field value of the response header at zero-based index index. Use the same index with ResponseHdrName to obtain the corresponding field name.

Repeated response fields occupy separate indexes and are returned in received order.

Returns null on failure

top
SendReqBd
public bool SendReqBd(string httpVerb, string uriPath, BinData body);
Introduced in version 9.5.0.62

Sends a request whose binary body is read from the BinData in body.

httpVerb is the HTTP method, such as GET, POST, or PUT. uriPath is the request path. This is a low-level send operation: after it succeeds, call ReadResponseHeader and then read the response body with the appropriate response method.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.

Returns true for success, false for failure.

top
SendReqBdAsync (C#) (PowerShell)
public Task SendReqBdAsync(string httpVerb, string uriPath, BinData body);
Introduced in version 9.5.0.62

Creates an asynchronous task to call the SendReqBd method with the arguments provided.

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 null on failure

top
SendReqBinaryBody
public bool SendReqBinaryBody(string httpVerb, string uriPath, byte[] body);
Introduced in version 9.5.0.58

Sends a request whose body is the binary byte array in body.

httpVerb is the HTTP method, such as GET, POST, or PUT. uriPath is the request path. This is a low-level send operation: after it succeeds, call ReadResponseHeader and then read the response body with the appropriate response method.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
Preferred binary API: For new code, SendReqBd uses BinData.

Returns true for success, false for failure.

top
SendReqBinaryBodyAsync (C#) (PowerShell)
public Task SendReqBinaryBodyAsync(string httpVerb, string uriPath, byte[] body);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqBinaryBody method with the arguments provided.

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 null on failure

top
SendReqFormUrlEncoded
public bool SendReqFormUrlEncoded(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Sends an application/x-www-form-urlencoded request. The request body is built from the parameters added with AddQueryParam or AddQueryParams. Any manually supplied Content-Type value is replaced with application/x-www-form-urlencoded.

httpVerb is the HTTP method, such as GET, POST, or PUT. uriPath is the request path. This is a low-level send operation: after it succeeds, call ReadResponseHeader and then read the response body with the appropriate response method.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.

Parameters written directly in uriPath remain in the URL query string. Parameters stored through AddQueryParam, AddQueryParamSb, or AddQueryParams are encoded into the form body. After the form request is sent, this stored parameter collection is cleared.

Persistent Content-Type: The method sets the top-level Content-Type to application/x-www-form-urlencoded. That request-header value remains configured for later requests until it is replaced or cleared.

Returns true for success, false for failure.

top
SendReqFormUrlEncodedAsync (C#) (PowerShell)
public Task SendReqFormUrlEncodedAsync(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqFormUrlEncoded method with the arguments provided.

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 null on failure

top
SendReqMultipart
public bool SendReqMultipart(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Sends a multipart request using the parts configured with PartSelector, AddHeader, and the multipart-body methods.

httpVerb is the HTTP method, such as GET, POST, or PUT. uriPath is the request path. This is a low-level send operation: after it succeeds, call ReadResponseHeader and then read the response body with the appropriate response method.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
Multipart state: Assigning a body to a selected part creates that part. Parts may be created out of numeric order, persist across multipart requests, and retain the generated boundary while the multipart structure remains configured. The default top-level media type is multipart/form-data.

The request fails if no multipart subparts are configured.

Returns true for success, false for failure.

top
SendReqMultipartAsync (C#) (PowerShell)
public Task SendReqMultipartAsync(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqMultipart method with the arguments provided.

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 null on failure

top
SendReqNoBody
public bool SendReqNoBody(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Sends a request without a request body.

httpVerb is the HTTP method, such as GET, POST, or PUT. uriPath is the request path. This is a low-level send operation: after it succeeds, call ReadResponseHeader and then read the response body with the appropriate response method.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.

Returns true for success, false for failure.

top
SendReqNoBodyAsync (C#) (PowerShell)
public Task SendReqNoBodyAsync(string httpVerb, string uriPath);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqNoBody method with the arguments provided.

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 null on failure

top
SendReqSb
public bool SendReqSb(string httpVerb, string uriPath, StringBuilder bodySb);
Introduced in version 9.5.0.62

Sends a request whose text body is read from the StringBuilder in bodySb. Set the request Content-Type header to identify the body format.

httpVerb is the HTTP method, such as GET, POST, or PUT. uriPath is the request path. This is a low-level send operation: after it succeeds, call ReadResponseHeader and then read the response body with the appropriate response method.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
Text encoding and Content-Type: Unicode text is encoded as UTF-8. Generic string-body methods do not automatically add a Content-Type header; add the media type required by the API, such as application/json; charset=utf-8.

Returns true for success, false for failure.

top
SendReqSbAsync (C#) (PowerShell)
public Task SendReqSbAsync(string httpVerb, string uriPath, StringBuilder bodySb);
Introduced in version 9.5.0.62

Creates an asynchronous task to call the SendReqSb method with the arguments provided.

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 null on failure

top
SendReqStreamBody
public bool SendReqStreamBody(string httpVerb, string uriPath, Stream stream);
Introduced in version 9.5.0.58

Sends a request whose body is read from the Stream in stream. The stream may supply text or binary data; set the request Content-Type header as required by the API.

httpVerb is the HTTP method, such as GET, POST, or PUT. uriPath is the request path. This is a low-level send operation: after it succeeds, call ReadResponseHeader and then read the response body with the appropriate response method.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
Streaming: The stream is consumed while the request is sent, which is useful when the body is too large to hold in memory.
Stream position: The stream is read from its current position and is left consumed. Reusing the same stream without resetting its source or position sends only the unread remainder, which may be zero bytes.

Returns true for success, false for failure.

top
SendReqStreamBodyAsync (C#) (PowerShell)
public Task SendReqStreamBodyAsync(string httpVerb, string uriPath, Stream stream);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqStreamBody method with the arguments provided.

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 null on failure

top
SendReqStringBody
public bool SendReqStringBody(string httpVerb, string uriPath, string bodyText);
Introduced in version 9.5.0.58

Sends a request whose text body is supplied in bodyText, such as JSON, XML, form-independent text, or another textual representation. Set the request Content-Type header to identify the body format expected by the server.

httpVerb is the HTTP method, such as GET, POST, or PUT. uriPath is the request path. This is a low-level send operation: after it succeeds, call ReadResponseHeader and then read the response body with the appropriate response method.

Request path: uriPath is the path and optional query portion of the URL, not a complete URL. For https://api.example.com/v1/items?limit=10, pass /v1/items?limit=10. The server name and port are established separately by Connect or UseConnection.
Text encoding and Content-Type: Unicode text is encoded as UTF-8. Generic string-body methods do not automatically add a Content-Type header; add the media type required by the API, such as application/json; charset=utf-8.

Returns true for success, false for failure.

top
SendReqStringBodyAsync (C#) (PowerShell)
public Task SendReqStringBodyAsync(string httpVerb, string uriPath, string bodyText);
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SendReqStringBody method with the arguments provided.

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 null on failure

top
SetAuthAws
public bool SetAuthAws(AuthAws authProvider);
Introduced in version 9.5.0.58

Associates the AuthAws provider in authProvider with this REST object. Chilkat uses the provider to sign each AWS request after the request method, path, query parameters, headers, and body are known. The application does not need to construct the Authorization header manually.

Request signing: AWS signatures cover selected request components. Add all required headers and query parameters before sending the request so the generated signature matches the final request.

Returns true for success, false for failure.

top
SetAuthAzureSas
public bool SetAuthAzureSas(AuthAzureSAS authProvider);
Introduced in version 9.5.0.65

Associates the AuthAzureSAS provider in authProvider with this REST object. Chilkat automatically adds an Authorization: SharedAccessSignature ... header to subsequent requests.

SAS terminology: This method is for Azure services that use a Shared Access Signature in the Authorization header. It is distinct from a storage SAS token embedded in a URL query string.

Returns true for success, false for failure.

top
SetAuthAzureStorage
public bool SetAuthAzureStorage(AuthAzureStorage authProvider);
Introduced in version 9.5.0.58

Associates the AuthAzureStorage provider in authProvider with this REST object. Chilkat automatically applies the Azure Storage authorization information required for each request.

Azure Storage authentication: The provider contains the storage account credentials and signing settings. Request-specific headers and the resource path are incorporated when the request is sent.

Returns true for success, false for failure.

top
SetAuthBasic
public bool SetAuthBasic(string username, string password);
Introduced in version 9.5.0.58

Configures HTTP Basic authentication using username as the username and password as the password. Chilkat automatically generates an Authorization: Basic ... header for subsequent requests.

Security requirement: Basic authentication is an encoding scheme, not encryption. Use it only over TLS. By default, Chilkat blocks Basic authentication on an insecure remote connection; AllowInsecureBasicAuth in UncommonOptions exists only for exceptional compatibility needs.

Some APIs use an account ID, client ID, API key, token, or secret in place of a traditional username or password; follow the service documentation.

Authorization precedence: The Basic authentication provider generates the Authorization header when each request is composed and takes precedence over a value set through the Authorization property or AddHeader.

Returns true for success, false for failure.

top
SetAuthBasicSecure
public bool SetAuthBasicSecure(SecureString username, SecureString password);
Introduced in version 9.5.0.71

Configures HTTP Basic authentication using the SecureString objects in username and password for the username and password. The resulting request behavior is the same as SetAuthBasic.

Credential handling: SecureString reduces unnecessary exposure of the credential text in ordinary application strings. Basic authentication must still be protected by TLS.
Authorization precedence: The Basic authentication provider generates the Authorization header when each request is composed and takes precedence over a manually configured Authorization value.

Returns true for success, false for failure.

top
SetAuthGoogle
public bool SetAuthGoogle(AuthGoogle authProvider);
Introduced in version 9.5.0.58

Associates the AuthGoogle provider in authProvider with this REST object. Chilkat uses the provider to add the Google authentication information needed by subsequent API requests.

Returns true for success, false for failure.

top
SetAuthOAuth1
public bool SetAuthOAuth1(OAuth1 authProvider, bool useQueryParams);
Introduced in version 9.5.0.58

Associates the OAuth1 provider in authProvider with this REST object for OAuth 1.0 or OAuth 1.0a request signing.

If useQueryParams is true, the OAuth parameters and signature are placed in the query string. If useQueryParams is false, they are placed in the Authorization header.

Final request matters: OAuth 1 signatures depend on the HTTP method, request URL, and parameters. Configure the request completely before sending it.

Returns true for success, false for failure.

top
SetAuthOAuth2
public bool SetAuthOAuth2(OAuth2 authProvider);
Introduced in version 9.5.0.59

Associates the OAuth2 provider in authProvider with this REST object. The provider must contain a valid access token. Chilkat then adds an Authorization: Bearer <access-token> header to each request.

The access token may be obtained through an OAuth flow or loaded from previously saved token data. Token acquisition, refresh, expiration, and scope requirements are determined by the authorization server.

Manual bearer headers: A bearer token can also be supplied with AddHeader. Do not configure both approaches for the same request because they compete for the same Authorization header.
Provider lifetime: The OAuth2 object is consulted when each request is composed rather than copied at setup time. Keep it alive while the Rest object uses it. Changing its AccessToken changes the bearer token used by subsequent requests.
Authorization precedence: The provider-generated bearer header takes precedence over a manually configured Authorization value.

Returns true for success, false for failure.

top
SetMultipartBodyBd
public bool SetMultipartBodyBd(BinData bodyData);
Introduced in version 9.5.0.62

Sets the binary body of the multipart part identified by PartSelector from the BinData in bodyData.

Setting the body creates the selected part when it does not already exist. Part numbers do not need to be created consecutively.

Returns true for success, false for failure.

top
SetMultipartBodyBinary
public bool SetMultipartBodyBinary(byte[] bodyData);
Introduced in version 9.5.0.58

Sets the selected multipart part body to the binary bytes in bodyData. The target part is identified by PartSelector.

Part headers: While the same part is selected, use AddHeader to set fields such as Content-Disposition and Content-Type. For new code, SetMultipartBodyBd uses BinData.

Setting the body creates the selected part when it does not already exist. Part numbers do not need to be created consecutively.

Returns true for success, false for failure.

top
SetMultipartBodySb
public bool SetMultipartBodySb(StringBuilder bodySb);
Introduced in version 9.5.0.62

Sets the text body of the multipart part identified by PartSelector from the StringBuilder in bodySb.

Setting the body creates the selected part when it does not already exist. Part numbers do not need to be created consecutively.

Returns true for success, false for failure.

top
SetMultipartBodyStream
public bool SetMultipartBodyStream(Stream stream);
Introduced in version 9.5.0.58

Uses the Stream in stream as the body source for the multipart part identified by PartSelector.

Large multipart parts: The stream is read while the request is sent, allowing a large file or generated body to be uploaded without first loading the entire part into memory.
Object lifetime and position: The selected part retains the stream as its body source until the multipart request is sent or the parts are cleared. Keep the Stream object alive. It is read from its current position and must be reset before reusing it for another upload.

Setting the body creates the selected part when it does not already exist. Part numbers do not need to be created consecutively.

Returns true for success, false for failure.

top
SetMultipartBodyString
public bool SetMultipartBodyString(string bodyText);
Introduced in version 9.5.0.58

Sets the text body of the multipart part identified by PartSelector to bodyText.

Part metadata: Use AddHeader while the part is selected to set its Content-Type, Content-Disposition, and other part headers.

Setting the body creates the selected part when it does not already exist. Part numbers do not need to be created consecutively.

Returns true for success, false for failure.

top
SetResponseBodyStream
public bool SetResponseBodyStream(int expectedStatus, bool autoSetStreamCharset, Stream responseStream);
Introduced in version 9.5.0.58

Configures a Stream destination for response bodies received by the full-request convenience methods. The body is written to responseStream only when the response status code matches expectedStatus.

If streaming occurs successfully, a string-returning full-request method returns OK. If streaming was selected but writing the body fails, it returns FAIL. If the status code does not match expectedStatus, the body is not streamed and remains available as the method's normal response text.

If autoSetStreamCharset is true and the response is textual, the destination stream's StringCharset is set from the response Content-Type charset when available. autoSetStreamCharset is ignored for binary responses.

expectedStatus valueStatus codes that are streamed
200Only 200
-200200 through 299
-210210 through 219
Resetting this behavior: Call ClearResponseBodyStream to restore normal response-body handling.

For Boolean-returning full-request methods, successful streaming returns true. A StringBuilder response output receives OK; a BinData response output is cleared. If the status does not match expectedStatus, the stream is not written and the method returns the response through its normal output.

The configuration remains active for later full-request calls until ClearResponseBodyStream is called.

Returns true for success, false for failure.

top
UseConnection
public bool UseConnection(Socket connection, bool autoReconnect);
Introduced in version 9.5.0.58

Uses the already-connected Socket in connection as the transport for REST requests. The socket may represent a direct TCP or TLS connection, an HTTP or SOCKS proxy connection, an SSH-tunneled channel, or another connection configured through the Socket API.

autoReconnect controls automatic reconnection for later requests when the connection is no longer usable.

When to use this method: Use Connect for ordinary direct connections. Use UseConnection when the connection requires advanced Socket configuration.
Socket lifetime: The Rest object retains and operates on the supplied Socket. Keep the Socket object alive while it is attached. Calling Disconnect disconnects it; with autoReconnect set to true, a later request can reconnect the same Socket object.

Returns true for success, false for failure.

top

Events

AbortCheck
public event AbortCheckEventHandler OnAbortCheck;

Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the HeartbeatMs property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second.

More Information and Examples

Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.AbortCheckEventArgs

Event callback implementation:

private void rest_OnAbortCheck(object sender, Chilkat.AbortCheckEventArgs args)
	{
	    // application code goes here.
	}

To add an event handler:

Chilkat.Rest rest = new Chilkat.Rest();
rest.OnAbortCheck += rest_OnAbortCheck;

Chilkat .NET Core Event Implementation

Event callback implementation:

public void handleAbortCheck(out bool abort)
	{
	    // application code goes here.
	}

To add an event handler:

Chilkat.Rest rest = new Chilkat.Rest();
// ...
Chilkat.Rest.AbortCheck abortCheck = new Chilkat.Rest.AbortCheck(handleAbortCheck);
rest.setAbortCheckCb(abortCheck);
top
PercentDone
public event PercentDoneEventHandler OnPercentDone;

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The pctDone argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have pctDone equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an AbortCheck event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

To abort the operation, set the abort output argument to true. This will cause the method to terminate and return a failure status or corresponding failure value.

More Information and Examples

Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.PercentDoneEventArgs

Event callback implementation:

private void rest_OnPercentDone(object sender, Chilkat.PercentDoneEventArgs args)
	{
	    // application code goes here.
	}

To add an event handler:

Chilkat.Rest rest = new Chilkat.Rest();
rest.OnPercentDone += rest_OnPercentDone;

Chilkat .NET Core Event Implementation

Event callback implementation:

public void handlePercentDone(int pctDone, out bool abort)
	{
	    // application code goes here.
	}

To add an event handler:

Chilkat.Rest rest = new Chilkat.Rest();
// ...
Chilkat.Rest.PercentDone percentDone = new Chilkat.Rest.PercentDone(handlePercentDone);
rest.setPercentDoneCb(percentDone);
top
ProgressInfo
public event ProgressInfoEventHandler OnProgressInfo;

This event callback provides tag name/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

Note: Some Chilkat methods don't fire any ProgressInfo events.

More Information and Examples

Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.ProgressInfoEventArgs

Event callback implementation:

private void rest_OnProgressInfo(object sender, Chilkat.ProgressInfoEventArgs args)
	{
	    // application code goes here.
	}

To add an event handler:

Chilkat.Rest rest = new Chilkat.Rest();
rest.OnProgressInfo += rest_OnProgressInfo;

Chilkat .NET Core Event Implementation

Event callback implementation:

public void handleProgressInfo(string name, string value)
	{
	    // application code goes here.
	}

To add an event handler:

Chilkat.Rest rest = new Chilkat.Rest();
// ...
Chilkat.Rest.ProgressInfo progressInfo = new Chilkat.Rest.ProgressInfo(handleProgressInfo);
rest.setProgressInfoCb(progressInfo);
top
TaskCompleted
public event TaskCompletedEventHandler OnTaskCompleted;

Called from the background thread when an asynchronous task completes.

Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.TaskCompletedEventArgs

Event callback implementation:

private void rest_OnTaskCompleted(object sender, Chilkat.TaskCompletedEventArgs args)
	{
	    // application code goes here.
	}

To add an event handler:

Chilkat.Rest rest = new Chilkat.Rest();
rest.OnTaskCompleted += rest_OnTaskCompleted;

Chilkat .NET Core Event Implementation

Event callback implementation:

public void handleTaskIdCompleted(int taskId)
	{
	    // application code goes here.
	}

To add an event handler:

Chilkat.Rest rest = new Chilkat.Rest();
// ...
Chilkat.Rest.TaskIdCompleted taskIdCompleted = new Chilkat.Rest.TaskIdCompleted(handleTaskIdCompleted);
rest.setTaskIdCompletedCb(taskIdCompleted);
top

Deprecated

LastJsonData
public JsonObject LastJsonData();
Introduced in version 9.5.0.79
This method is deprecated.

Deprecated. Use GetLastJsonData instead.

Returns a JSON object containing operation-specific details from the most recently completed method when such details are available. Many operations produce an empty object.

Returns null on failure

top
RedirectUrl
public Url RedirectUrl();
Introduced in version 9.5.0.58
This method is deprecated.

Deprecated. Use LastRedirectUrl instead.

If the most recent response is a redirect and contains a Location header, returns that redirect URL.

Returns null on failure

top