Class JsonClient
Implements a light-weight JSON oriented HTTP client.
Namespace: Neon.Net
Assembly: Neon.Common.dll
Syntax
public class JsonClient
Remarks
Use GetAsync(string, ArgDictionary, ArgDictionary, CancellationToken), PutAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken), PostAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken), DeleteAsync(string, ArgDictionary, ArgDictionary, CancellationToken), OptionsAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken), HeadAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken), or PatchAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken) to perform HTTP operations that ensure that a non-error HTTP status code is returned by the servers.
Use GetUnsafeAsync(string, ArgDictionary, ArgDictionary, CancellationToken), PutUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken), PostUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken), DeleteUnsafeAsync(string, ArgDictionary, ArgDictionary, CancellationToken), OptionsUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken), HeadUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken), or PatchUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken) to perform an HTTP without ensuring a non-error HTTP status code.
This class can also handle retrying operations when transient errors are detected. Customize SafeRetryPolicy and/or UnsafeRetryPolicy by setting a IRetryPolicy implementation such as LinearRetryPolicy or ExponentialRetryPolicy.
note
This class initializes SafeRetryPolicy to a reasonable ExponentialRetryPolicy by default and UnsafeRetryPolicy to NoRetryPolicy. You can override the default retry policy for specific requests using the methods that take an IRetryPolicy as their first parameter.
note
The JsonClientPayload class can be used to customize both the Content-Type header and the actual payload uploaded with POST and PUT requests. This can be used for those special REST APIs that don't accept JSON payloads.
All you need to do is construct a JsonClientPayload instance, specifying the value to be used as the Content-Type header and the payload data as text or a byte array and then pass this as the document parameter to the methods that upload content. The methods will recognize this special type and just send the specified data rather than attempting to serailize the document to JSON.
Constructors
JsonClient(HttpClient)
Used in special situations (like ASP.NET Blazor) where a special HttpClient needs to be created and provided.
Declaration
public JsonClient(HttpClient httpClient)
Parameters
Type | Name | Description |
---|---|---|
HttpClient | httpClient | The special HttpClient instance to be wrapped. |
JsonClient(HttpMessageHandler, bool)
Used to construct a client for most situations, optionally specifying a custom HttpMessageHandler.
Declaration
public JsonClient(HttpMessageHandler handler = null, bool disposeHandler = false)
Parameters
Type | Name | Description |
---|---|---|
HttpMessageHandler | handler | The optional message handler. |
bool | disposeHandler | Indicates whether the handler passed will be disposed automatically (defaults to |
Properties
BaseAddress
The default base Uri the client will use when relative URIs are specified for requests.
Declaration
public Uri BaseAddress { get; set; }
Property Value
Type | Description |
---|---|
Uri |
DefaultRequestHeaders
Returns the base client's default request headers property to make it easy to customize request headers.
Declaration
public HttpRequestHeaders DefaultRequestHeaders { get; }
Property Value
Type | Description |
---|---|
HttpRequestHeaders |
DocumentType
Specifies the MIME type to use posting or putting documents to the endpoint. This defaults to the standard application/json but some services may require custom values.
Declaration
public string DocumentType { get; set; }
Property Value
Type | Description |
---|---|
string |
HttpClient
Returns the underlying HttpClient.
Declaration
public HttpClient HttpClient { get; }
Property Value
Type | Description |
---|---|
HttpClient |
SafeRetryPolicy
The IRetryPolicy to be used to detect and retry transient network and HTTP errors for the safe methods. This defaults to ExponentialRetryPolicy with the transient detector function set to NetworkOrHttp(Exception).
note
You may set this to null
to disable safe transient error retry.
Declaration
public IRetryPolicy SafeRetryPolicy { get; set; }
Property Value
Type | Description |
---|---|
IRetryPolicy |
Timeout
The default base Uri the client will use when relative URIs are specified for requests.
Declaration
public TimeSpan Timeout { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
UnsafeRetryPolicy
The IRetryPolicy to be used to detect and retry transient network errors for the unsafe methods. This defaults to NoRetryPolicy.
note
You may set this to null
to disable unsafe transient error retry.
Declaration
public IRetryPolicy UnsafeRetryPolicy { get; set; }
Property Value
Type | Description |
---|---|
IRetryPolicy |
Methods
DeleteAsync(IRetryPolicy, string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP DELETE using a specific IRetryPolicy and ensuring that a success code was returned.
Declaration
public Task<JsonResponse> DeleteAsync(IRetryPolicy retryPolicy, string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
DeleteAsync(string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP DELETE ensuring that a success code was returned.
Declaration
public Task<JsonResponse> DeleteAsync(string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
DeleteAsync<TResult>(string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP DELETE returning a specific type and ensuring that a success cxode was returned.
Declaration
public Task<TResult> DeleteAsync<TResult>(string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<TResult> | The JsonResponse. |
Type Parameters
Name | Description |
---|---|
TResult | The desired result type. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
DeleteUnsafeAsync(IRetryPolicy, string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP DELETE using a specific IRetryPolicy and without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> DeleteUnsafeAsync(IRetryPolicy retryPolicy, string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
DeleteUnsafeAsync(string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP DELETE without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> DeleteUnsafeAsync(string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
Dispose()
Releases all resources associated with the instance.
Declaration
public void Dispose()
Dispose(bool)
Releases all associated resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | Pass |
~JsonClient()
Finalizer.
Declaration
protected ~JsonClient()
GetAsync(IRetryPolicy, string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP GET using a specific IRetryPolicy" and ensuring that a success code was returned.
Declaration
public Task<JsonResponse> GetAsync(IRetryPolicy retryPolicy, string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
GetAsync(string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP GET ensuring that a success code was returned.
Declaration
public Task<JsonResponse> GetAsync(string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
GetAsync<TResult>(string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP GET returning a specific type and ensuring that a success code was returned.
Declaration
public Task<TResult> GetAsync<TResult>(string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<TResult> | The JsonResponse. |
Type Parameters
Name | Description |
---|---|
TResult | The desired result type. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
GetUnsafeAsync(IRetryPolicy, string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP GET using a specific IRetryPolicy and without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> GetUnsafeAsync(IRetryPolicy retryPolicy, string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
GetUnsafeAsync(string, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP GET without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> GetUnsafeAsync(string uri, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HeadAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP HEAD using a specific IRetryPolicy and ensuring that a success code was returned.
Declaration
public Task HeadAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task | The tracking Task. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
HeadAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP HEAD ensuring that a success code was returned.
Declaration
public Task HeadAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task | The tracking Task. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
HeadAsync<TResult>(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP HEAD returning a specific type and ensuring that a success code was returned.
Declaration
public Task HeadAsync<TResult>(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task | The tracking Task. |
Type Parameters
Name | Description |
---|---|
TResult | The desired result type. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
HeadUnsafeAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP HEAD using a specific IRetryPolicy and without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> HeadUnsafeAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HeadUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP HEAD without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> HeadUnsafeAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
OptionsAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP OPTIONS using a specific IRetryPolicy and ensuring that a success code was returned.
Declaration
public Task<JsonResponse> OptionsAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
OptionsAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP OPTIONS ensuring that a success code was returned.
Declaration
public Task<JsonResponse> OptionsAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
OptionsAsync<TResult>(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP OPTIONS returning a specific type and ensuring that a success code was returned.
Declaration
public Task<TResult> OptionsAsync<TResult>(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<TResult> | The JsonResponse. |
Type Parameters
Name | Description |
---|---|
TResult | The desired result type. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
OptionsUnsafeAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP OPTIONS using a specific IRetryPolicy and without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> OptionsUnsafeAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
OptionsUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP OPTIONS without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> OptionsUnsafeAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
PatchAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PATCH using a specific IRetryPolicy and ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PatchAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
PatchAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PATCH ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PatchAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
PatchAsync<TResult>(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PATCH returning a specific type and ensuring that a success code was returned.
Declaration
public Task<TResult> PatchAsync<TResult>(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<TResult> | The JsonResponse. |
Type Parameters
Name | Description |
---|---|
TResult | The desired result type. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
PatchUnsafeAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PATCH using a specific IRetryPolicy and without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PatchUnsafeAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
PatchUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PATCH without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PatchUnsafeAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
PostAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP POST using a specific IRetryPolicy and ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PostAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
PostAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP POST ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PostAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
PostAsync<TResult>(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP POST returning a specific type and ensuring that a success code was returned.
Declaration
public Task<TResult> PostAsync<TResult>(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<TResult> | The JsonResponse. |
Type Parameters
Name | Description |
---|---|
TResult | The desired result type. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
PostUnsafeAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP POST using a specific IRetryPolicy and without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PostUnsafeAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
PostUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP POST without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PostUnsafeAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
PutAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PUT using a specific IRetryPolicy" and ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PutAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
PutAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PUT ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PutAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
PutAsync<TResult>(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PUT returning a specific type and ensuring that a success code was returned.
Declaration
public Task<TResult> PutAsync<TResult>(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<TResult> | The JsonResponse. |
Type Parameters
Name | Description |
---|---|
TResult | The desired result type. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
HttpException | Thrown when the server responds with an HTTP error status code. |
PutUnsafeAsync(IRetryPolicy, string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PUT using a specific IRetryPolicy" and without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PutUnsafeAsync(IRetryPolicy retryPolicy, string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IRetryPolicy | retryPolicy | The retry policy or |
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |
PutUnsafeAsync(string, object, ArgDictionary, ArgDictionary, CancellationToken)
Performs an HTTP PUT without ensuring that a success code was returned.
Declaration
public Task<JsonResponse> PutUnsafeAsync(string uri, object document = null, ArgDictionary args = null, ArgDictionary headers = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The target URI. |
object | document | The optional object to be uploaded as the request payload. This may be JSON text, a plain old object that will be serialized as JSON or a StreamDocument to upload body data from a Stream. |
ArgDictionary | args | The optional query arguments. |
ArgDictionary | headers | The Optional HTTP headers. |
CancellationToken | cancellationToken | The optional CancellationToken. |
Returns
Type | Description |
---|---|
Task<JsonResponse> | The JsonResponse. |
Exceptions
Type | Condition |
---|---|
SocketException | Thrown for network connectivity issues. |