Table of Contents

Class Request

Namespace
FrApp42.Web.API
Assembly
FrApp42.Web.dll
public class Request
Inheritance
Request
Inherited Members

Constructors

Request(string)

Initializes a new instance of the Request class with the specified URL.

public Request(string url)

Parameters

url string

The URL to send the request to.

Request(string, HttpMethod)

Initializes a new instance of the Request class with the specified URL and HTTP method.

public Request(string url, HttpMethod method)

Parameters

url string

The URL to send the request to.

method HttpMethod

The HTTP method to use for the request.

Properties

Body

Gets the JSON body content of the request.

public object Body { get; }

Property Value

object

ContentHeaders

Gets the content headers.

public Dictionary<string, string> ContentHeaders { get; }

Property Value

Dictionary<string, string>

ContentType

Gets the content type of the request.

public string ContentType { get; }

Property Value

string

DocumentBody

Gets the binary document content of the request.

public byte[] DocumentBody { get; }

Property Value

byte[]

DocumentFileName

Gets the name of the binary document file.

public string? DocumentFileName { get; }

Property Value

string

Method

Gets the HTTP method to use for the request.

public HttpMethod Method { get; }

Property Value

HttpMethod

QueryParams

Gets the query parameters.

public Dictionary<string, string> QueryParams { get; }

Property Value

Dictionary<string, string>

RequestHeaders

Gets the request headers.

public Dictionary<string, string> RequestHeaders { get; }

Property Value

Dictionary<string, string>

URL

Gets the URL to send the request to.

public string URL { get; }

Property Value

string

Methods

AcceptJson()

Adds an "Accept" header with the value "application/json" to the request.

public Request AcceptJson()

Returns

Request

Instance

AddByteBody(byte[], string?)

Adds a byte[] to the request content.

public Request AddByteBody(byte[] document, string? fileName)

Parameters

document byte[]

The binary file content.

fileName string

The name of the file.

Returns

Request

Instance

AddContentHeader(string, string)

Adds a content header to the request

public Request AddContentHeader(string key, string value)

Parameters

key string

The content header key.

value string

The content header value.

Returns

Request

Instance

AddContentHeaders(Dictionary<string, string>)

Adds multiple content headers from a dictionary of key-value pairs to the request.

public Request AddContentHeaders(Dictionary<string, string> headers)

Parameters

headers Dictionary<string, string>

Content headers in dictionary.

Returns

Request

Instance

AddHeader(string, string)

Adds a header to the request.

public Request AddHeader(string key, string value)

Parameters

key string

The header key.

value string

The header value.

Returns

Request

Instance

AddHeaders(Dictionary<string, string>)

Adds multiple headers from a dictionary of key-value pairs to the request.

public Request AddHeaders(Dictionary<string, string> headers)

Parameters

headers Dictionary<string, string>

Headers in dictionary.

Returns

Request

Instance

AddJsonBody(object)

Adds a JSON body to the request content.

public Request AddJsonBody(object body)

Parameters

body object

The JSON body content.

Returns

Request

Instance

AddQueryParam(string, string)

Adds a query parameter to the request.

public Request AddQueryParam(string key, string value)

Parameters

key string

The query parameter key.

value string

The query parameter value.

Returns

Request

Instance

AddQueryParams(Dictionary<string, string>)

Adds multiple content headers from a dictionary of key-value pairs to the request.

public Request AddQueryParams(Dictionary<string, string> queryParams)

Parameters

queryParams Dictionary<string, string>

Query parameters in dictionary.

Returns

Request

Instance

RunBinaryRaw<T>()

Executes the HTTP request by sending the raw binary content directly in the request body, without using multipart encoding. This method is ideal for APIs expecting direct binary content, equivalent to Postman's "Binary" body type.

public Task<Result<T>> RunBinaryRaw<T>()

Returns

Task<Result<T>>

A Result<T> object containing the deserialized response, the HTTP status code, and any error message if the request fails.

Type Parameters

T

The type of the expected response.

RunDocument<T>()

Executes the HTTP request and returns the response content as a byte array.

public Task<Result<T>> RunDocument<T>()

Returns

Task<Result<T>>

A Result object containing the response.

Type Parameters

T

The type of the response expected from the request.

RunGetBytes()

Executes the HTTP request that will return a byte array.

public Task<Result<byte[]>> RunGetBytes()

Returns

Task<Result<byte[]>>

A Result<T> object containing the response content as a byte array, the status code of the response, and any error message if the request fails.

Run<T>()

Executes the HTTP request with the JSON body content included.

public Task<Result<T>> Run<T>()

Returns

Task<Result<T>>

A Result object containing the response.

Type Parameters

T

The type of the response expected from the request.

SetContentType(string)

Sets the content type of the request.

public Request SetContentType(string contentType)

Parameters

contentType string

The content type of the request.

Returns

Request

Instance