HttpsRequestHandler Methods

Represents a wrapper around the class HttpClient. It provides an abstraction so you can interact with an Http Request with a single method.

Definition

Namespace: Tipi.Tools.Http

Assembly: Tipi.Tools.Http.dll

Package: Tipi.Tools.HttpRequestHandler

Executes the HTTP Verb provided to the endpoint provided.

Executes the HTTP Verb provided to the endpoint provided passing a JSON string as Body Object.

Dispose the HttpClient.

ExecuteAsync(String, String)

Executes the HTTP Verb provided to the endpoint provided, this method is awaitable.

Copied!

                    
    // Create a new instance of the HttpRequestHandler Class
    using var requestHandler = new HttpRequestHandler();
    // Execute the http verb provided on the endpoint provided
    var response = await requestHandler.ExecuteAsync("GET", "https://codex.codingtipi.com/api/v1/langs");
                    
                
ExecuteAsync(String, String, String)

Executes the HTTP Verb provided to the endpoint provided and pass as the third parameter a JSON object string, this method is awaitable.

Copied!

                    
    // Create a new instance of the HttpRequestHandler Class
    using var requestHandler = new HttpRequestHandler();
    // Create my object
    var bodyObject = new { Id = 1, Name = "Example" };
    // Stringify my object using the Newtonsoft library
    var stringBodyObject = JsonConvert.SerializeObject(bodyObject)
    // Execute the http verb provided on the endpoint provided
    var response = await requestHandler.ExecuteAsync("POST", "https://codex.codingtipi.com/api/v1/langs", stringBodyObject);
                    
                
Dispose()

Disposes the HttpClient.

Copied!

                    
    // Create a new instance of the HttpRequestHandler Class
    using var requestHandler = new HttpRequestHandler();
    // Dispose
    var response = await requestHandler.Dispose();