RestSharp
Allows "basic access authentication" for HTTP requests.
Encoding can be specified depending on what your server expect (see https://stackoverflow.com/a/7243567).
UTF-8 is used by default but some servers might expect ISO-8859-1 encoding.
JSON WEB TOKEN (JWT) Authenticator class.
https://tools.ietf.org/html/draft-ietf-oauth-json-web-token
Set the new bearer token so the request gets the new header value
The set of characters that are unreserved in RFC 2396 but are NOT unreserved in RFC 3986.
Generates a random 16-byte lowercase alphanumeric string.
Generates a timestamp based on the current elapsed seconds since '01/01/1970 0000 GMT"
Generates a timestamp based on the elapsed seconds of a given time since '01/01/1970 0000 GMT"
A specified point in time.
URL encodes a string based on section 5.1 of the OAuth spec.
Namely, percent encoding with [RFC3986], avoiding unreserved characters,
upper-casing hexadecimal characters, and UTF-8 encoding for text value pairs.
The value to escape.
The escaped value.
The method is supposed to take on
RFC 3986 behavior if certain elements are present in a .config file. Even if this
actually worked (which in my experiments it doesn't), we can't rely on every
host actually having this configuration element present.
URL encodes a string based on section 5.1 of the OAuth spec.
Namely, percent encoding with [RFC3986], avoiding unreserved characters,
upper-casing hexadecimal characters, and UTF-8 encoding for text value pairs.
Sorts a collection of key-value pairs by name, and then value if equal,
concatenating them into a single string. This string should be encoded
prior to, or after normalization is run.
Sorts a by name, and then value if equal.
A collection of parameters to sort
A sorted parameter collection
Creates a request URL suitable for making OAuth requests.
Resulting URLs must exclude port 80 or port 443 when accompanied by HTTP and HTTPS, respectively.
Resulting URLs must be lower case.
The original request URL
Creates a request elements concatenation value to send with a request.
This is also known as the signature base.
The request HTTP method type
The request URL
The request parameters
A signature base string
Creates a signature value given a signature base and the consumer secret.
This method is used when the token secret is currently unknown.
The hashing method
The signature base
The consumer key
Creates a signature value given a signature base and the consumer secret.
This method is used when the token secret is currently unknown.
The hashing method
The treatment to use on a signature value
The signature base
The consumer key
Creates a signature value given a signature base and the consumer secret and a known token secret.
The hashing method
The treatment to use on a signature value
The signature base
The consumer secret
The token secret
A class to encapsulate OAuth authentication flow.
Generates an OAuth signature to pass to an
for the purpose of requesting an
unauthorized request token.
The HTTP method for the intended request
Any existing, non-OAuth query parameters desired in the request
Generates an OAuth signature to pass to the
for the purpose of exchanging a request token
for an access token authorized by the user at the Service Provider site.
The HTTP method for the intended request
Any existing, non-OAuth query parameters desired in the request
Generates an OAuth signature to pass to an
for the purpose of exchanging user credentials
for an access token authorized by the user at the Service Provider site.
The HTTP method for the intended request
Any existing, non-OAuth query parameters desired in the request
RFC: The OAuth 1.0 Protocol
The OAuth 2 authenticator using the authorization request header field.
Based on http://tools.ietf.org/html/draft-ietf-oauth-v2-10#section-5.1.1
Initializes a new instance of the class.
The access token.
Initializes a new instance of the class.
The access token.
The token type.
The OAuth 2 authenticator using URI query parameter.
Based on http://tools.ietf.org/html/draft-ietf-oauth-v2-10#section-5.1.2
Initializes a new instance of the class.
The access token.
Builds the URI for the request
Client instance
Request instance
Builds the URI for the request without query parameters.
Client instance
Request instance
Gets the query string for the request.
Client instance
Request instance
Types of parameters that can be added to requests
A that will added to the QueryString for GET, DELETE, OPTIONS and HEAD requests; and form for POST and PUT requests.
See .
A that will be added to part of the url by replacing a {placeholder} within the absolute path.
See .
A that will be added as a request header
See .
A that will be added to the request body
See .
A that will be added to the query string
See .
Data formats
HTTP method to use when making requests
Format strings for commonly-used date formats
.NET format string for ISO 8601 date format
.NET format string for roundtrip date format
Status for responses (surprised?)
Not Applicable, for when the Request has not yet been made
for when the request is passes as a result of being true, or when the response is
for when the request fails due as a result of being false except for the case when the response is
for when the Operation is cancelled due to the request taking longer than the length of time prescribed by or due to the timing out.
for when the Operation is cancelled, due to reasons other than
Reflection extensions
Retrieve an attribute from a member (property)
Type of attribute to retrieve
Member to retrieve attribute from
Retrieve an attribute from a type
Type of attribute to retrieve
Type to retrieve attribute from
Checks a type to see if it derives from a raw generic (e.g. List[[]])
Find a value from a System.Enum by trying several possible variants
of the string value of the enum.
Type of enum
Value for which to search
The culture used to calculate the name variants
Extension method overload!
Read a stream into a byte array
Stream to read
byte[]
Uses Uri.EscapeDataString() based on recommendations on MSDN
http://blogs.msdn.com/b/yangxind/archive/2006/11/09/don-t-use-net-system-uri-unescapedatastring-in-url-decoding.aspx
Client options that aren't used for configuring HttpClient
Client-level serializers
Default parameters to use on every request made with this client instance.
Executes the request asynchronously, authenticating if needed
Request to be executed
Cancellation token
A specialized method to download files as streams.
Pre-configured request instance.
The downloaded stream.
Base URL for all requests made with this client instance
Custom configuration for the underlying
Function to calculate the response status. By default, the status will be Completed if it was successful, or NotFound.
Authenticator that will be used to populate request with necessary authentication data
Passed to Credentials
property
Determine whether or not the "default credentials" (e.g. the user account under which the current process is
running) will be sent along to the server. The default is false.
Passed to UseDefaultCredentials
property
Set to true if you need the Content-Type not to have the charset
Set the decompression method to use when making requests
Set the maximum number of redirects to follow
X509CertificateCollection to be sent with request
Set the proxy to use when making requests. Default is null, which will use the default system proxy if one is set.
Cache policy to be used for requests using
Instruct the client to follow redirects. Default is true.
Gets or sets a value that indicates if the header for an HTTP request contains Continue.
Value of the User-Agent header to be sent with requests. Default is "RestSharp/{version}"
Passed to property
Callback function for handling the validation of remote certificates. Useful for certificate pinning and
overriding certificate errors in the scope of a request.
Sets the value of the Host header to be sent with requests.
Custom cookie container to be used for requests. RestSharp will not assign the container to the message handler,
but will fetch cookies from it and set them on the request.
Maximum request duration in milliseconds. When the request timeout is specified using ,
the lowest value between the client timeout and request timeout will be used.
Default encoding to use when no encoding is specified in the content type header.
Set to true to throw an exception when a deserialization error occurs. Default is false.
When set to true, the response status will be set to
when a deserialization error occurs. Default is true.
Set to true to throw an exception when throws an exception when making a request.
Default is false.
Set to true to allow multiple default parameters with the same name. Default is false.
Custom function to encode a string for use in a URL.
Custom function to encode a string for use in a URL query.
Body parameter data type
Custom content encoding
Safely add a default parameter to the collection.
Parameter to add
Safely removes all the default parameters with the given name and type.
Parameter name
Parameter type
Replace a default parameter with the same name and type.
Parameter instance
Container for files to be uploaded with requests
Name of the parameter
Name of the file to use when uploading
MIME content type of file
Provides raw data for file
Creates a file parameter from an array of bytes.
The parameter name to use in the request.
The data to use as the file's contents.
The filename to use in the request.
The content type to use in the request.
File parameter options
The
Creates a file parameter from an array of bytes.
The parameter name to use in the request.
Delegate that will be called with the request stream so you can write to it..
The filename to use in the request.
Optional: parameter content type, default is "application/g-zip"
File parameter options
The using the default content type.
Instantiates an HTTP parameter instance (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)
Name of the parameter
Value of the parameter
Encode the value or not, default true
Instantiates a header parameter
Parameter name
Parameter value
Parameter container for REST requests
Parameter container for REST requests
MIME content type of the parameter
Return a human-readable representation of this parameter
String
Instantiates a new query parameter instance that will be added to the request URL as {name}={value} part of the query string.
Parameter name
Parameter value
Optional: encode the value, default is true
Instantiates a new query parameter instance that will be added to the request URL by replacing part of the absolute path.
The request resource should have a placeholder {name} that will be replaced with the parameter value when the request is made.
Parameter name
Parameter value
Optional: encode the value, default is true
Gets parameters from the provided object
The object from which to get the parameters
Properties to include, or nothing to include everything. The array will be sorted.
Gets parameters from the provided object
The object from which to get the parameters
Gets the name of the property this populator represents.
This corresponds to the actual property name and not the name
determined by
Populates the provided parameters collection
The object to get parameters from
The parameters collection to populate
Creates a new populator instance from the provided property
A public instance property from the type
Gets or sets the associated
with the property this object represents
Gets the associated with
the property this object represents
Gets the associated
with the property this object represents
Gets the return type of the property this object represents
Creates a new request property representation of the provided property
The property to turn into a request property
Container for data used to make requests
Default constructor
Constructor for a rest request to a relative resource URL and optional method
Resource to use
Method to use (defaults to Method.Get>
Constructor for a rest request to a specific resource Uri and optional method
Resource Uri to use
Method to use (defaults to Method.Get>
Always send a multipart/form-data request - even when no Files are present.
When set to true, parameter values in a multipart form data requests will be enclosed in
quotation marks. Default is false. Enable it if the remote endpoint requires parameters
to be in quotes (for example, FreshDesk API).
When set to true, the form boundary part of the content type will be enclosed in
quotation marks. Default is true.
Overrides the default (random) form boundary
Container of all HTTP parameters to be passed with the request.
See AddParameter() for explanation of the types of parameters that can be passed
Optional cookie container to use for the request. If not set, cookies are not passed.
Request-level authenticator. It will be used if set, otherwise RestClient.Authenticator will be used.
Container of all the files to be uploaded with the request.
Determines what HTTP method to use for this request. Supported methods: GET, POST, PUT, DELETE, HEAD, OPTIONS
Default is GET
Custom request timeout
The Resource URL to make the request against.
Tokens are substituted with UrlSegment parameters and match by name.
Should not include the scheme or domain. Do not include leading slash.
Combined with RestClient.BaseUrl to assemble final URL:
{BaseUrl}/{Resource} (BaseUrl is scheme + domain, e.g. http://example.com)
// example for url token replacement
request.Resource = "Products/{ProductId}";
request.AddParameter("ProductId", 123, ParameterType.UrlSegment);
Serializer to use when writing request bodies.
Used by the default deserializers to determine where to start deserializing from.
Can be used to skip container or root elements that do not have corresponding deserialzation targets.
When supplied, the function will be called before calling the deserializer
When supplied, the function will be called before making a request
When supplied, the function will be called after the request is complete
How many attempts were made to send this Request
This number is incremented each time the RestClient sends the request.
Completion option for
Cache policy to be used for requests using
Set this to write response to Stream rather than reading into memory.
Set this to handle the response stream yourself, based on the response details
Adds a parameter object to the request parameters
Parameter to add
Removes a parameter object from the request parameters
Parameter to remove
Adds a HTTP parameter to the request (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)
Name of the parameter
Value of the parameter
Encode the value or not, default true
This request
Adds a HTTP parameter to the request (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)
Request instance
Name of the parameter
Value of the parameter
Encode the value or not, default true
This request
Adds or updates a HTTP parameter to the request (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)
Request instance
Name of the parameter
Value of the parameter
Encode the value or not, default true
This request
Adds or updates a HTTP parameter to the request (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)
Request instance
Name of the parameter
Value of the parameter
Encode the value or not, default true
This request
Adds a URL segment parameter to the request. The resource URL must have a placeholder for the parameter for it to work.
For example, if you add a URL segment parameter with the name "id", the resource URL should contain {id} in its path.
Request instance
Name of the parameter, must be matching a placeholder in the resource URL as {name}
Value of the parameter
Encode the value or not, default true
Adds a URL segment parameter to the request. The resource URL must have a placeholder for the parameter for it to work.
For example, if you add a URL segment parameter with the name "id", the resource URL should contain {id} in its path.
Request instance
Name of the parameter, must be matching a placeholder in the resource URL as {name}
Value of the parameter
Encode the value or not, default true
Adds a query string parameter to the request. The request resource should not contain any placeholders for this parameter.
The parameter will be added to the request URL as a query string using name=value format.
Request instance
Parameter name
Parameter value
Encode the value or not, default true
Adds a query string parameter to the request. The request resource should not contain any placeholders for this parameter.
The parameter will be added to the request URL as a query string using name=value format.
Request instance
Parameter name
Parameter value
Encode the value or not, default true
Adds a header to the request. RestSharp will try to separate request and content headers when calling the resource.
Request instance
Header name
Header value
Adds a header to the request. RestSharp will try to separate request and content headers when calling the resource.
Request instance
Header name
Header value
Adds or updates the request header. RestSharp will try to separate request and content headers when calling the resource.
Existing header with the same name will be replaced.
Request instance
Header name
Header value
Adds or updates the request header. RestSharp will try to separate request and content headers when calling the resource.
Existing header with the same name will be replaced.
Request instance
Header name
Header value
Adds multiple headers to the request, using the key-value pairs provided.
Request instance
Collection of key-value pairs, where key will be used as header name, and value as header value
Adds or updates multiple headers to the request, using the key-value pairs provided. Existing headers with the same name will be replaced.
Request instance
Collection of key-value pairs, where key will be used as header name, and value as header value
Adds a parameter of a given type to the request. It will create a typed parameter instance based on the type argument.
It is not recommended to use this overload unless you must, as it doesn't provide any restrictions, and if the name-value-type
combination doesn't match, it will throw.
Request instance
Name of the parameter, must be matching a placeholder in the resource URL as {name}
Value of the parameter
Enum value specifying what kind of parameter is being added
Encode the value or not, default true
Adds or updates request parameter of a given type. It will create a typed parameter instance based on the type argument.
Parameter will be added or updated based on its name. If the request has a parameter with the same name, it will be updated.
It is not recommended to use this overload unless you must, as it doesn't provide any restrictions, and if the name-value-type
combination doesn't match, it will throw.
Request instance
Name of the parameter, must be matching a placeholder in the resource URL as {name}
Value of the parameter
Enum value specifying what kind of parameter is being added
Encode the value or not, default true
Adds or updates request parameter, given the parameter instance, for example or .
It will replace an existing parameter with the same name.
Request instance
Parameter instance
Adds or updates multiple request parameters, given the parameter instance, for example
or . Parameters with the same name will be replaced.
Request instance
Collection of parameter instances
Adds a file parameter to the request body. The file will be read from disk as a stream.
Request instance
Parameter name
Full path to the file
Optional: content type
File parameter header options
Adds bytes to the request as file attachment
Request instance
Parameter name
File content as bytes
File name
Optional: content type. Default is "application/octet-stream"
File parameter header options
Adds a file attachment to the request, where the file content will be retrieved from a given stream
Request instance
Parameter name
Function that returns a stream with the file content
File name
Optional: content type. Default is "application/octet-stream"
File parameter header options
Adds a body parameter to the request
Request instance
Object to be used as the request body, or string for plain content
Optional: content type
Thrown if request body type cannot be resolved
This method will try to figure out the right content type based on the request data format and the provided content type
Adds a string body and figures out the content type from the data format specified. You can, for example, add a JSON string
using this method as request body, using DataFormat.Json/>
Request instance
String body
for the content
Adds a string body to the request using the specified content type.
Request instance
String body
Content type of the body
Adds a JSON body parameter to the request from a string
Request instance
Force serialize the top-level string
Optional: content type. Default is "application/json"
JSON string to be used as a body
Adds a JSON body parameter to the request
Request instance
Object that will be serialized to JSON
Optional: content type. Default is "application/json"
Adds an XML body parameter to the request
Request instance
Object that will be serialized to XML
Optional: content type. Default is "application/xml"
Optional: XML namespace
Gets object properties and adds each property as a form data parameter
Request instance
Object to add as form data
Properties to include, or nothing to include everything. The array will be sorted.
Gets object properties and adds each property as a form data parameter
This method gets public instance properties from the provided type
rather than from itself, which allows for caching of properties and
other optimizations. If you don't know the type at runtime, or wish to use properties not
available from the provided type parameter, consider using
Request instance
Object to add as form data
Properties to include, or nothing to include everything. The array will be sorted.
Gets object properties and adds each property as a form data parameter
This method gets public instance properties from the provided type
rather than from itself, which allows for caching of properties and
other optimizations. If you don't know the type at runtime, or wish to use properties not
available from the provided type parameter, consider using
Request instance
Object to add as form data
Adds cookie to the cookie container.
RestRequest to add the cookies to
Cookie name
Cookie value
Cookie path
Cookie domain, must not be an empty string
Used by the default deserializers to explicitly set which date format string to use when parsing dates.
Used by XmlDeserializer. If not specified, XmlDeserializer will flatten response by removing namespaces from
element names.
Container for data sent back from API including deserialized data
Type of data to deserialize to
Deserialized entity data
Container for data sent back from API
Base class for common properties shared by RestResponse and RestResponse[[T]]
Default constructor
The RestRequest that was made to get this RestResponse
Mainly for debugging if ResponseStatus is not OK
MIME content type of response
Length in bytes of the response content
Encoding of the response content
String representation of response content
HTTP response status code
Whether or not the HTTP response status code indicates success
Whether or not the HTTP response status code indicates success and no other error occurred (deserialization, timeout, ...)
Description of HTTP status returned
Response content
The URL that actually responded to the content (different from request if redirected)
HttpWebResponse.Server
Cookies returned by server with the response
Response headers returned by server with the response
Content headers returned by server with the response
Status of the request. Will return Error for transport errors.
HTTP errors will still return ResponseStatus.Completed, check StatusCode instead
Transport or other non-HTTP error generated while attempting request
The exception thrown during the request, if any
HTTP protocol version of the request
Root element of the serialized response content, only works if deserializer supports it
Assists with debugging responses by displaying in the debugger output
Client to translate RestRequests into Http requests and process response result
Content types that will be sent in the Accept header. The list is populated from the known serializers.
If you need to send something else by default, set this property to a different value.
>
>
Creates an instance of RestClient using the provided
Client options
Delegate to add default headers to the wrapped HttpClient instance
Delegate to configure serialization
Set to true if you wish to reuse the instance
Creates an instance of RestClient using the default
Delegate to configure the client options
Delegate to add default headers to the wrapped HttpClient instance
Delegate to configure serialization
Set to true if you wish to reuse the instance
Creates an instance of RestClient using a specific BaseUrl for requests made by this client instance
Base URI for the new client
Delegate to configure the client options
Delegate to add default headers to the wrapped HttpClient instance
Delegate to configure serialization
Set to true if you wish to reuse the instance
Creates an instance of RestClient using a specific BaseUrl for requests made by this client instance
Base URI for this new client as a string
Delegate to configure the client options
Delegate to add default headers to the wrapped HttpClient instance
Delegate to configure serialization
Creates an instance of RestClient using a shared HttpClient and specific RestClientOptions and does not allocate one internally.
HttpClient to use
RestClient options to use
True to dispose of the client, false to assume the caller does (defaults to false)
Delegate to configure serialization
Creates an instance of RestClient using a shared HttpClient and does not allocate one internally.
HttpClient to use
True to dispose of the client, false to assume the caller does (defaults to false)
Delegate to configure the client options
Delegate to configure serialization
Creates a new instance of RestSharp using the message handler provided. By default, HttpClient disposes the provided handler
when the client itself is disposed. If you want to keep the handler not disposed, set disposeHandler argument to false.
Message handler instance to use for HttpClient
Dispose the handler when disposing RestClient, true by default
Delegate to configure the client options
Delegate to configure serialization
Executes a GET-style request asynchronously, authenticating if needed.
The response content then gets deserialized to T.
Target deserialization type
Request to be executed
Cancellation token
Deserialized response content
Executes a GET-style asynchronously, authenticating if needed
Request to be executed
Cancellation token
Executes a POST-style request asynchronously, authenticating if needed.
The response content then gets deserialized to T.
Target deserialization type
Request to be executed
The cancellation token
Deserialized response content
Executes a POST-style asynchronously, authenticating if needed
Request to be executed
Cancellation token
Executes a PUT-style request asynchronously, authenticating if needed.
The response content then gets deserialized to T.
Target deserialization type
Request to be executed
The cancellation token
Deserialized response content
Executes a PUP-style asynchronously, authenticating if needed
Request to be executed
Cancellation token
Executes the request asynchronously, authenticating if needed
Target deserialization type
Request to be executed
Cancellation token
Executes the request asynchronously, authenticating if needed
Request to be executed
Override the request method
Cancellation token
Executes the request asynchronously, authenticating if needed
Target deserialization type
Request to be executed
Override the request method
Cancellation token
Execute the request using GET HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Cancellation token
Expected result type
Execute the request using POST HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Cancellation token
Expected result type
Execute the request using PUT HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Cancellation token
Expected result type
Execute the request using HEAD HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Cancellation token
Expected result type
Execute the request using OPTIONS HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Cancellation token
Expected result type
Execute the request using PATCH HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Cancellation token
Expected result type
Execute the request using DELETE HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Cancellation token
Expected result type
A specialized method to download files.
RestClient instance
Pre-configured request instance.
The downloaded file.
Reads a stream returned by the specified endpoint, deserializes each line to JSON and returns each object asynchronously.
It is required for each JSON object to be returned in a single line.
Calls the URL specified in the resource
parameter, expecting a JSON response back. Deserializes and returns the response.
RestClient instance
Resource URL
Cancellation token
Response object type
Calls the URL specified in the resource
parameter, expecting a JSON response back. Deserializes and returns the response.
RestClient instance
Resource URL
Parameters to pass to the request
Cancellation token
Response object type
Deserialized response object
Serializes the request
object to JSON and makes a POST call to the resource specified in the resource
parameter.
Expects a JSON response back, deserializes it to TResponse
type and returns it.
RestClient instance
Resource URL
Request object, must be serializable to JSON
Cancellation token
Request object type
Response object type
Deserialized response object
Serializes the request
object to JSON and makes a POST call to the resource specified in the resource
parameter.
Expects no response back, just the status code.
RestClient instance
Resource URL
Request object, must be serializable to JSON
Cancellation token
Request object type
Response status code
Serializes the request
object to JSON and makes a PUT call to the resource specified in the resource
parameter.
Expects a JSON response back, deserializes it to TResponse
type and returns it.
RestClient instance
Resource URL
Request object, must be serializable to JSON
Cancellation token
Request object type
Response object type
Deserialized response object
Serializes the request
object to JSON and makes a PUT call to the resource specified in the resource
parameter.
Expects no response back, just the status code.
RestClient instance
Resource URL
Request object, must be serializable to JSON
Cancellation token
Request object type
Response status code
Add a parameter to use on every request made with this client instance
instance
to add
Adds a default HTTP parameter (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)
Used on every request made by this client instance
instance
Name of the parameter
Value of the parameter
This request
Adds a default parameter to the client options. There are four types of parameters:
- GetOrPost: Either a QueryString value or encoded form value based on method
- HttpHeader: Adds the name/value pair to the HTTP request's Headers collection
- UrlSegment: Inserted into URL if there is a matching url token e.g. {AccountId}
- RequestBody: Used by AddBody() (not recommended to use directly)
Used on every request made by this client instance
instance
Name of the parameter
Value of the parameter
The type of parameter to add
This request
Adds a default header to the RestClient. Used on every request made by this client instance.
instance
Name of the header to add
Value of the header to add
Adds default headers to the RestClient. Used on every request made by this client instance.
instance
Dictionary containing the Names and Values of the headers to add
Adds a default URL segment parameter to the RestClient. Used on every request made by this client instance.
instance
Name of the segment to add
Value of the segment to add
Adds a default URL query parameter to the RestClient. Used on every request made by this client instance.
instance
Name of the query parameter to add
Value of the query parameter to add
Executes the request synchronously, authenticating if needed
Request to be executed
The cancellation token
A specialized method to download files as streams.
Pre-configured request instance.
The cancellation token
The downloaded stream.
Calls the URL specified in the resource
parameter, expecting a JSON response back. Deserializes and returns the response.
RestClient instance
Resource URL
Response object type
Deserialized response object
Calls the URL specified in the resource
parameter, expecting a JSON response back. Deserializes and returns the response.
RestClient instance
Resource URL
Parameters to pass to the request
Response object type
Deserialized response object
Serializes the request
object to JSON and makes a POST call to the resource specified in the resource
parameter.
Expects a JSON response back, deserializes it to TResponse
type and returns it.
RestClient instance
Resource URL
Request object, must be serializable to JSON
Request object type
Response object type
Deserialized response object
Serializes the request
object to JSON and makes a POST call to the resource specified in the resource
parameter.
Expects no response back, just the status code.
RestClient instance
Resource URL
Request object, must be serializable to JSON
Request object type
Response status code
Serializes the request
object to JSON and makes a PUT call to the resource specified in the resource
parameter.
Expects a JSON response back, deserializes it to TResponse
type and returns it.
RestClient instance
Resource URL
Request object, must be serializable to JSON
Request object type
Response object type
Deserialized response object
Serializes the request
object to JSON and makes a PUT call to the resource specified in the resource
parameter.
Expects no response back, just the status code.
RestClient instance
Resource URL
Request object, must be serializable to JSON
Request object type
Response status code
Use System.Text.Json serializer with default settings
Use System.Text.Json serializer with custom settings
System.Text.Json serializer options
Create the new serializer that uses System.Text.Json.JsonSerializer with default settings
Create the new serializer that uses System.Text.Json.JsonSerializer with custom settings
Json serializer settings
Deserialize the response content into the specified type
Response instance
Deserialized model type
Replace the default serializer with a custom one
Function that returns the serializer instance
Replace the default serializer with a custom one
The type that implements
Sets the to only use JSON
Configuration instance to work with
Reference to the client instance
Sets the to only use XML
Configuration instance to work with
Reference to the client instance
Sets the to only use the passed in custom serializer
Configuration instance to work with
Function that returns the serializer instance
Reference to the client instance
Wrapper for System.Xml.Serialization.XmlSerializer.
Encoding for serialized content
Name of the root element to use when serializing
XML namespace to use when serializing
Wrapper for System.Xml.Serialization.XmlSerializer.
Default constructor, does not specify namespace
Specify the namespaced to be used when serializing
XML namespace
Encoding for serialized content
Serialize the object as XML
Object to serialize
XML as string
Name of the root element to use when serializing
XML namespace to use when serializing
Content type for serialized content
Executes a task synchronously on the calling thread by installing a temporary synchronization context that queues continuations
Callback for asynchronous task to run
Executes a task synchronously on the calling thread by installing a temporary synchronization context that queues continuations
Callback for asynchronous task to run
Return type for the task
Return value from the task
Synchronization context that can be "pumped" in order to have it execute continuations posted back to it
Constructor for the custom context
Task to execute
When overridden in a derived class, dispatches an asynchronous message to a synchronization context.
Callback function
Callback state
Enqueues the function to be executed and executes all resulting continuations until it is completely done
When overridden in a derived class, dispatches a synchronous message to a synchronization context.
Callback function
Callback state
When overridden in a derived class, creates a copy of the synchronization context. Not needed, so just return ourselves.
Copy of the context
Executes a GET-style request synchronously, authenticating if needed.
The response content then gets deserialized to T.
Target deserialization type
Request to be executed
Deserialized response content
Executes a GET-style synchronously, authenticating if needed
Request to be executed
Executes a POST-style request synchronously, authenticating if needed.
The response content then gets deserialized to T.
Target deserialization type
Request to be executed
Deserialized response content
Executes a POST-style synchronously, authenticating if needed
Request to be executed
Executes a PUT-style request synchronously, authenticating if needed.
The response content then gets deserialized to T.
Target deserialization type
Request to be executed
Deserialized response content
Executes a PUP-style synchronously, authenticating if needed
Request to be executed
Executes the request synchronously, authenticating if needed
Target deserialization type
Request to be executed
Executes the request synchronously, authenticating if needed
Request to be executed
Override the request method
Executes the request synchronously, authenticating if needed
Target deserialization type
Request to be executed
Override the request method
Execute the request using GET HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Expected result type
Execute the request using POST HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Expected result type
Execute the request using PUT HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Expected result type
Execute the request using HEAD HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Expected result type
Execute the request using OPTIONS HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Expected result type
Execute the request using PATCH HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Expected result type
Execute the request using DELETE HTTP method. Exception will be thrown if the request does not succeed.
The response data is deserialized to the Data property of the returned response object.
RestClient instance
The request
Expected result type
A specialized method to download files.
RestClient instance
Pre-configured request instance.
The downloaded file.