Search Results for

    Show / Hide Table of Contents

    Class HttpClientExtensions

    a set of extensions to the httpclient in order to facilitate route-less integration testing

    Inheritance
    object
    HttpClientExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastEndpoints
    Assembly: FastEndpoints.dll
    Syntax
    public static class HttpClientExtensions

    Methods

    DELETEAsync<TEndpoint, TResponse>(HttpClient)

    make a DELETE request to an endpoint using auto route discovery without a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> DELETEAsync<TEndpoint, TResponse>(this HttpClient client) where TEndpoint : IEndpoint
    Parameters
    Type Name Description
    HttpClient client
    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TResponse

    the type of the response dto

    DELETEAsync<TRequest, TResponse>(HttpClient, string, TRequest, bool)

    make a DELETE request using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> DELETEAsync<TRequest, TResponse>(this HttpClient client, string requestUri, TRequest request, bool populateHeaders = true) where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    string requestUri

    the route url to post to

    TRequest request

    the request dto

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TRequest

    type of the request dto

    TResponse

    type of the response dto

    DELETEAsync<TEndpoint, TRequest>(HttpClient, TRequest, bool)

    make a DELETE request to an endpoint using auto route discovery using a request dto that does not send back a response dto.

    Declaration
    public static Task<HttpResponseMessage> DELETEAsync<TEndpoint, TRequest>(this HttpClient client, TRequest request, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<HttpResponseMessage>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    DELETEAsync<TEndpoint, TRequest, TResponse>(HttpClient, TRequest, bool)

    make a DELETE request to an endpoint using auto route discovery using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> DELETEAsync<TEndpoint, TRequest, TResponse>(this HttpClient client, TRequest request, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    TResponse

    the type of the response dto

    GETAsync<TEndpoint, TResponse>(HttpClient)

    make a GET request to an endpoint using auto route discovery without a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> GETAsync<TEndpoint, TResponse>(this HttpClient client) where TEndpoint : IEndpoint
    Parameters
    Type Name Description
    HttpClient client
    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TResponse

    the type of the response dto

    GETAsync<TRequest, TResponse>(HttpClient, string, TRequest, bool)

    make a GET request using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> GETAsync<TRequest, TResponse>(this HttpClient client, string requestUri, TRequest request, bool populateHeaders = true) where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    string requestUri

    the route url to post to

    TRequest request

    the request dto

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TRequest

    type of the request dto

    TResponse

    type of the response dto

    GETAsync<TEndpoint, TRequest>(HttpClient, TRequest, bool)

    make a GET request to an endpoint using auto route discovery using a request dto that does not send back a response dto.

    Declaration
    public static Task<HttpResponseMessage> GETAsync<TEndpoint, TRequest>(this HttpClient client, TRequest request, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<HttpResponseMessage>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    GETAsync<TEndpoint, TRequest, TResponse>(HttpClient, TRequest, bool)

    make a GET request to an endpoint using auto route discovery using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> GETAsync<TEndpoint, TRequest, TResponse>(this HttpClient client, TRequest request, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    TResponse

    the type of the response dto

    PATCHAsync<TEndpoint, TResponse>(HttpClient)

    make a PATCH request to an endpoint using auto route discovery without a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> PATCHAsync<TEndpoint, TResponse>(this HttpClient client) where TEndpoint : IEndpoint
    Parameters
    Type Name Description
    HttpClient client
    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TResponse

    the type of the response dto

    PATCHAsync<TRequest, TResponse>(HttpClient, string, TRequest, bool, bool)

    make a PATCH request using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> PATCHAsync<TRequest, TResponse>(this HttpClient client, string requestUri, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    string requestUri

    the route url to PATCH to

    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TRequest

    type of the request dto

    TResponse

    type of the response dto

    PATCHAsync<TEndpoint, TRequest>(HttpClient, TRequest, bool, bool)

    make a PATCH request to an endpoint using auto route discovery using a request dto that does not send back a response dto.

    Declaration
    public static Task<HttpResponseMessage> PATCHAsync<TEndpoint, TRequest>(this HttpClient client, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<HttpResponseMessage>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    PATCHAsync<TEndpoint, TRequest, TResponse>(HttpClient, TRequest, bool, bool)

    make a PATCH request to an endpoint using auto route discovery using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> PATCHAsync<TEndpoint, TRequest, TResponse>(this HttpClient client, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    TResponse

    the type of the response dto

    POSTAsync<TEndpoint, TResponse>(HttpClient)

    make a POST request to an endpoint using auto route discovery without a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> POSTAsync<TEndpoint, TResponse>(this HttpClient client) where TEndpoint : IEndpoint
    Parameters
    Type Name Description
    HttpClient client
    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TResponse

    the type of the response dto

    POSTAsync<TRequest, TResponse>(HttpClient, string, TRequest, bool, bool)

    make a POST request using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO/>.

    Declaration
    public static Task<TestResult<TResponse>> POSTAsync<TRequest, TResponse>(this HttpClient client, string requestUri, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    string requestUri

    the route url to post to

    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TRequest

    type of the request dto

    TResponse

    type of the response dto

    POSTAsync<TEndpoint, TRequest>(HttpClient, TRequest, bool, bool)

    make a POST request to an endpoint using auto route discovery using a request dto that does not send back a response dto.

    Declaration
    public static Task<HttpResponseMessage> POSTAsync<TEndpoint, TRequest>(this HttpClient client, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<HttpResponseMessage>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    POSTAsync<TEndpoint, TRequest, TResponse>(HttpClient, TRequest, bool, bool)

    make a POST request to an endpoint using auto route discovery using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> POSTAsync<TEndpoint, TRequest, TResponse>(this HttpClient client, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    TResponse

    the type of the response dto

    PUTAsync<TEndpoint, TResponse>(HttpClient)

    make a PUT request to an endpoint using auto route discovery without a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> PUTAsync<TEndpoint, TResponse>(this HttpClient client) where TEndpoint : IEndpoint
    Parameters
    Type Name Description
    HttpClient client
    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TResponse

    the type of the response dto

    PUTAsync<TRequest, TResponse>(HttpClient, string, TRequest, bool, bool)

    make a PUT request using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> PUTAsync<TRequest, TResponse>(this HttpClient client, string requestUri, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    string requestUri

    the route url to post to

    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TRequest

    type of the request dto

    TResponse

    type of the response dto

    PUTAsync<TEndpoint, TRequest>(HttpClient, TRequest, bool, bool)

    make a PUT request to an endpoint using auto route discovery using a request dto that does not send back a response dto.

    Declaration
    public static Task<HttpResponseMessage> PUTAsync<TEndpoint, TRequest>(this HttpClient client, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<HttpResponseMessage>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    PUTAsync<TEndpoint, TRequest, TResponse>(HttpClient, TRequest, bool, bool)

    make a PUT request to an endpoint using auto route discovery using a request dto and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO.

    Declaration
    public static Task<TestResult<TResponse>> PUTAsync<TEndpoint, TRequest, TResponse>(this HttpClient client, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TEndpoint : IEndpoint where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to true, headers will be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TEndpoint

    the type of the endpoint

    TRequest

    the type of the request dto

    TResponse

    the type of the response dto

    SENDAsync<TRequest, TResponse>(HttpClient, HttpMethod, string, TRequest, bool, bool)

    send a request DTO to a given endpoint URL and get back a TestResult<TResponse> containing the HttpResponseMessage as well as the TResponse DTO

    Declaration
    public static Task<TestResult<TResponse>> SENDAsync<TRequest, TResponse>(this HttpClient client, HttpMethod method, string requestUri, TRequest request, bool sendAsFormData = false, bool populateHeaders = true) where TRequest : notnull
    Parameters
    Type Name Description
    HttpClient client
    HttpMethod method

    the http method to use

    string requestUri

    the route url of the endpoint

    TRequest request

    the request dto

    bool sendAsFormData

    when set to true, the request dto will be automatically converted to a MultipartFormDataContent

    bool populateHeaders

    when set to false, headers will not be automatically added to the http request from request dto properties decorated with the [FromHeader] attribute.

    Returns
    Type Description
    Task<TestResult<TResponse>>
    Type Parameters
    Name Description
    TRequest

    type of the request dto

    TResponse

    type of the response dto

    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX