docs.unity3d.com
    Show / Hide Table of Contents

    Class HttpClientJsonExtensions

    Helper methods for IHttpClient

    Inheritance
    Object
    HttpClientJsonExtensions
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Cloud.Common
    Syntax
    public static class HttpClientJsonExtensions

    Methods

    DeleteJsonAsync(IHttpClient, String, Object, HttpCompletionOption, IProgress<HttpProgress>, CancellationToken)

    Asynchronously performs a Delete-request, using Json to serialize payload/>

    Declaration
    public static Task<HttpResponseMessage> DeleteJsonAsync(this IHttpClient httpClient, string requestUri, object payload, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, IProgress<HttpProgress> progress = null, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IHttpClient httpClient

    The HTTP client.

    String requestUri

    The Uri the request is sent to

    Object payload

    Optional Object that will be used as content of the request message

    HttpCompletionOption completionOption

    When the operation should complete.

    IProgress<HttpProgress> progress

    The progress provider.

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task<HttpResponseMessage>

    A task that will hold the HttpResponseMessage once the request is completed

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the requestUri is null or empty.

    HttpRequestException

    Thrown when an HTTP response can't be obtained from the server.

    TaskCanceledException

    Thrown when the request is cancelled by a cancellation token.

    TimeoutException

    Thrown when the request failed due to timeout.

    DeleteJsonAsync<TModel>(IHttpClient, String, Object, HttpCompletionOption, IProgress<HttpProgress>, CancellationToken)

    Asynchronously performs a Delete-request, using Json to serialize payload and deserialize response to a TModel

    Declaration
    public static async Task<TModel> DeleteJsonAsync<TModel>(this IHttpClient httpClient, string requestUri, object payload = null, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, IProgress<HttpProgress> progress = null, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IHttpClient httpClient

    The HTTP client.

    String requestUri

    The Uri the request is sent to

    Object payload

    Optional Object that will be used as content of the request message

    HttpCompletionOption completionOption

    When the operation should complete.

    IProgress<HttpProgress> progress

    The progress provider.

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task<TModel>

    A task that will hold the TModel once the request is completed

    Type Parameters
    Name Description
    TModel

    The type the response is deserialized to

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the requestUri is null or empty.

    HttpRequestException

    Thrown when an HTTP response can't be obtained from the server.

    TaskCanceledException

    Thrown when the request is cancelled by a cancellation token.

    TimeoutException

    Thrown when the request failed due to timeout.

    GetJsonAsync<TModel>(IHttpClient, String, HttpCompletionOption, IProgress<HttpProgress>, CancellationToken)

    Asynchronously performs a Get-request using Json to deserialize response to a TModel

    Declaration
    public static async Task<TModel> GetJsonAsync<TModel>(this IHttpClient httpClient, string requestUri, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, IProgress<HttpProgress> progress = null, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IHttpClient httpClient

    The HTTP client.

    String requestUri

    The Uri the request is sent to

    HttpCompletionOption completionOption

    When the operation should complete.

    IProgress<HttpProgress> progress

    The progress provider.

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task<TModel>

    A task that will hold the TModel once the request is completed

    Type Parameters
    Name Description
    TModel

    The type the response is deserialized to

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the requestUri is null or empty.

    HttpRequestException

    Thrown when an HTTP response can't be obtained from the server.

    TaskCanceledException

    Thrown when the request is cancelled by a cancellation token.

    TimeoutException

    Thrown when the request failed due to timeout.

    PatchJsonAsync<TModel>(IHttpClient, String, Object, HttpCompletionOption, IProgress<HttpProgress>, CancellationToken)

    Asynchronously performs a Patch-request, using Json to serialize payload and deserialize response to a TModel

    Declaration
    public static async Task<TModel> PatchJsonAsync<TModel>(this IHttpClient httpClient, string requestUri, object payload = null, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, IProgress<HttpProgress> progress = null, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IHttpClient httpClient

    The HTTP client.

    String requestUri

    The Uri the request is sent to

    Object payload

    Optional Object that will be used as content of the request message

    HttpCompletionOption completionOption

    When the operation should complete.

    IProgress<HttpProgress> progress

    The progress provider.

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task<TModel>

    A task that will hold the TModel once the request is completed

    Type Parameters
    Name Description
    TModel

    The type the response is deserialized to

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the requestUri is null or empty.

    HttpRequestException

    Thrown when an HTTP response can't be obtained from the server.

    TaskCanceledException

    Thrown when the request is cancelled by a cancellation token.

    TimeoutException

    Thrown when the request failed due to timeout.

    PostJsonAsync<TModel>(IHttpClient, String, Object, HttpCompletionOption, IProgress<HttpProgress>, CancellationToken)

    Asynchronously performs a Post-request, using Json to serialize payload and deserialize response to a TModel

    Declaration
    public static async Task<TModel> PostJsonAsync<TModel>(this IHttpClient httpClient, string requestUri, object payload = null, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, IProgress<HttpProgress> progress = null, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IHttpClient httpClient

    The HTTP client.

    String requestUri

    The Uri the request is sent to

    Object payload

    Optional Object that will be used as content of the request message

    HttpCompletionOption completionOption

    When the operation should complete.

    IProgress<HttpProgress> progress

    The progress provider.

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task<TModel>

    A task that will hold the TModel once the request is completed

    Type Parameters
    Name Description
    TModel

    The type the response is deserialized to

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the requestUri is null or empty.

    HttpRequestException

    Thrown when an HTTP response can't be obtained from the server.

    TaskCanceledException

    Thrown when the request is cancelled by a cancellation token.

    TimeoutException

    Thrown when the request failed due to timeout.

    PutJsonAsync<TModel>(IHttpClient, String, Object, HttpCompletionOption, IProgress<HttpProgress>, CancellationToken)

    Asynchronously performs a Put-request, using Json to serialize payload and deserialize response to a TModel

    Declaration
    public static async Task<TModel> PutJsonAsync<TModel>(this IHttpClient httpClient, string requestUri, object payload = null, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, IProgress<HttpProgress> progress = null, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IHttpClient httpClient

    The HTTP client.

    String requestUri

    The Uri the request is sent to

    Object payload

    Optional Object that will be used as content of the request message

    HttpCompletionOption completionOption

    When the operation should complete.

    IProgress<HttpProgress> progress

    The progress provider.

    CancellationToken cancellationToken

    Optional cancellation token that will try to cancel the operation.

    Returns
    Type Description
    Task<TModel>

    A task that will hold the TModel once the request is completed

    Type Parameters
    Name Description
    TModel

    The type the response is deserialized to

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the requestUri is null or empty.

    HttpRequestException

    Thrown when an HTTP response can't be obtained from the server.

    TaskCanceledException

    Thrown when the request is cancelled by a cancellation token.

    TimeoutException

    Thrown when the request failed due to timeout.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023