EnhancedWebRequest 1.0.6
See the version list below for details.
dotnet add package EnhancedWebRequest --version 1.0.6
NuGet\Install-Package EnhancedWebRequest -Version 1.0.6
<PackageReference Include="EnhancedWebRequest" Version="1.0.6" />
paket add EnhancedWebRequest --version 1.0.6
#r "nuget: EnhancedWebRequest, 1.0.6"
// Install EnhancedWebRequest as a Cake Addin #addin nuget:?package=EnhancedWebRequest&version=1.0.6 // Install EnhancedWebRequest as a Cake Tool #tool nuget:?package=EnhancedWebRequest&version=1.0.6
Enhanced Web Request
Yet another web API client for .net 8
Introduction
This package provides basic web API functionality using HttpClient
with HttpRequestMessage
and HttpResponseMessage
in .net 8.
Most methods handling entity data use JSON with the System.Text.Json
library, except the specific file upload methods (which use content type multipart/form-data
)
and the old-style form POST methods (which use content type application/x-www-form-urlencoded
).
Example Usage
There are three constructors to the EnhancedWebRequest
class:
public EnhancedWebRequest(HttpClient httpClient)
public EnhancedWebRequest(HttpClientHandler clientHandler)
public EnhancedWebRequest(string baseUrl, EnhancedWebRequestOptions options)
Assuming we have an existing HttpClient
object called httpClient
and an entity of type MyClass
, we can send a PUT request to update the entity on the remote service:
var webReq = new EnhancedWebRequest(httpClient);
var entity = new MyClass() { Prop = "value", Id = 1234 };
var updatedEntity = await webReq.MakeJsonEntityRequest<MyClass>($"https://api.example.com/rest/entity/{entity.Id}", "PUT", entity);
If a base URI was set in the EnhancedWebRequest
object at the time of its creation, any URI passed to a specific request method call will be handled as follows:
- If the URI passed to the request method is an absolute URI, it will be used in the current request method call as the request URI, overriding the base URI in the class if one is set.
- If the URI passed to the request method is a relative URI, it will be concatenated with the existing base URI of the request object, and the resulting URI will be used in the current request method call as the request URI.
- If the URI passed to the request method is a relative URI and no base URI is set in the request object, an exception is thrown.
Issues
There are probably more robust libraries out there for interacting with web APIs. This package is still in its infancy.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EnhancedWebRequest:
Package | Downloads |
---|---|
NpiRegistry
A client package for interacting with the National Provider Identifier (NPI) registry API. |
GitHub repositories
This package is not used by any popular GitHub repositories.