RestSharp by John Sheehan, RestSharp Community

<PackageReference Include="RestSharp" Version="106.4.2" />

 IRestRequest

public interface IRestRequest

Set this to handle the response stream yourself, based on the response details

List of Allowed Decompression Methods

bool AlwaysMultipartFormData { get; set; }

Always send a multipart/form-data request - even when no Files are present.

int Attempts { get; }

How many attempts were made to send this Request?

ICredentials Credentials { get; set; }

In general you would not need to set this directly. Used by the NtlmAuthenticator.

string DateFormat { get; set; }

Used by the default deserializers to explicitly set which date format string to use when parsing dates.

Container of all the files to be uploaded with the request.

Serializer to use when writing JSON request bodies. Used if RequestFormat is Json. By default the included JsonSerializer is used (currently using JSON.NET default serialization).

Method Method { get; set; }

Determines what HTTP method to use for this request. Supported methods: GET, POST, PUT, DELETE, HEAD, OPTIONS Default is GET

Container of all HTTP parameters to be passed with the request. See AddParameter() for explanation of the types of parameters that can be passed

int ReadWriteTimeout { get; set; }

The number of milliseconds before the writing or reading times out. This timeout value overrides a timeout set on the RestClient.

DataFormat RequestFormat { get; set; }

Serializer to use when writing XML request bodies. Used if RequestFormat is Xml. By default XmlSerializer is used.

string Resource { get; set; }

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)

Action<Stream> ResponseWriter { get; set; }

Set this to write response to Stream rather than reading into memory.

string RootElement { get; set; }

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.

int Timeout { get; set; }

Timeout in milliseconds to be used for the request. This timeout value overrides a timeout set on the RestClient.

bool UseDefaultCredentials { get; set; }

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.

string XmlNamespace { get; set; }

Used by XmlDeserializer. If not specified, XmlDeserializer will flatten response by removing namespaces from element names.

ISerializer XmlSerializer { get; set; }

Serializer to use when writing XML request bodies. Used if RequestFormat is Xml. By default the included XmlSerializer is used.

IRestRequest AddBody(object obj, string xmlNamespace)

Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer The default format is XML. Change RequestFormat if you wish to use a different serialization format.

IRestRequest AddBody(object obj)

Serializes obj to data format specified by RequestFormat and adds it to the request body. The default format is XML. Change RequestFormat if you wish to use a different serialization format.

IRestRequest AddCookie(string name, string value)

Shortcut to AddParameter(name, value, Cookie) overload

IRestRequest AddFile(string name, string path, string contentType = null)

Adds a file to the Files collection to be included with a POST or PUT request (other methods do not support file uploads).

IRestRequest AddFile(string name, byte[] bytes, string fileName, string contentType = null)

Adds the bytes to the Files collection with the specified file name and content type

IRestRequest AddFile(string name, Action<Stream> writer, string fileName, long contentLength, string contentType = null)

Adds the bytes to the Files collection with the specified file name and content type

IRestRequest AddFileBytes(string name, byte[] bytes, string filename, string contentType = "application/x-gzip")

Add bytes to the Files collection as if it was a file of specific type

IRestRequest AddHeader(string name, string value)

Shortcut to AddParameter(name, value, HttpHeader) overload

Serializes obj to JSON format and adds it to the request body.

IRestRequest AddObject(object obj, string[] includedProperties)

Calls AddParameter() for all public, readable properties specified in the includedProperties list

IRestRequest AddObject(object obj)

Calls AddParameter() for all public, readable properties of obj

Add or update the parameter to the request

IRestRequest AddOrUpdateParameter(string name, object value)

Adds a HTTP parameter to the request (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)

IRestRequest AddOrUpdateParameter(string name, object value, ParameterType type)

Adds a parameter to the request. There are five 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} - Cookie: Adds the name/value pair to the HTTP request's Cookies collection - RequestBody: Used by AddBody() (not recommended to use directly)

IRestRequest AddOrUpdateParameter(string name, object value, string contentType, ParameterType type)

Adds a parameter to the request. There are five 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} - Cookie: Adds the name/value pair to the HTTP request's Cookies collection - RequestBody: Used by AddBody() (not recommended to use directly)

Add the parameter to the request

IRestRequest AddParameter(string name, object value)

Adds a HTTP parameter to the request (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)

IRestRequest AddParameter(string name, object value, ParameterType type)

Adds a parameter to the request. There are five 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} - Cookie: Adds the name/value pair to the HTTP request's Cookies collection - RequestBody: Used by AddBody() (not recommended to use directly)

IRestRequest AddParameter(string name, object value, string contentType, ParameterType type)

Adds a parameter to the request. There are five 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} - Cookie: Adds the name/value pair to the HTTP request's Cookies collection - RequestBody: Used by AddBody() (not recommended to use directly)

IRestRequest AddQueryParameter(string name, string value)

Shortcut to AddParameter(name, value, QueryString) overload

IRestRequest AddQueryParameter(string name, string value, bool encode)

Shortcut to AddParameter(name, value, QueryString) overload

IRestRequest AddUrlSegment(string name, string value)

Shortcut to AddParameter(name, value, UrlSegment) overload

Serializes obj to XML format and adds it to the request body.

IRestRequest AddXmlBody(object obj, string xmlNamespace)

Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer Serializes obj to XML format and passes xmlNamespace then adds it to the request body.