SweetMeSoft.Connectivity 1.10.130

dotnet add package SweetMeSoft.Connectivity --version 1.10.130
                    
NuGet\Install-Package SweetMeSoft.Connectivity -Version 1.10.130
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SweetMeSoft.Connectivity" Version="1.10.130" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SweetMeSoft.Connectivity" Version="1.10.130" />
                    
Directory.Packages.props
<PackageReference Include="SweetMeSoft.Connectivity" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SweetMeSoft.Connectivity --version 1.10.130
                    
#r "nuget: SweetMeSoft.Connectivity, 1.10.130"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SweetMeSoft.Connectivity@1.10.130
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SweetMeSoft.Connectivity&version=1.10.130
                    
Install as a Cake Addin
#tool nuget:?package=SweetMeSoft.Connectivity&version=1.10.130
                    
Install as a Cake Tool

SweetMeSoft.Connectivity

Library to simplify and standardize requests to APIs and web services.

Description

SweetMeSoft.Connectivity is a library for .NET Standard 2.1 that provides an ApiReq class as a wrapper over HttpClient. Its goal is to facilitate making HTTP requests (GET, POST, PUT, DELETE), handling different content types, cookie management and response deserialization in a structured and reusable way.

Features

  • HttpClient Wrapper: Abstracts the complexity of HttpClient into a simpler API.
  • HTTP Methods Support: Implements GET, POST, PUT and DELETE.
  • Content Handling: Supports application/json, application/x-www-form-urlencoded and multipart/form-data.
  • Generic Classes: Uses GenericReq<T> for requests and GenericRes<T> for responses, allowing strong typing.
  • Cookie Management: Automatically manages cookies between requests.
  • File Download: Includes a DownloadFile method to get files as a StreamFile.
  • Singleton Pattern: Provides a single instance through ApiReq.Instance for easy access.

Dependencies

Installation

dotnet add package SweetMeSoft.Connectivity

Usage

The library is used through the singleton instance ApiReq.Instance.

GenericReq<T>: The Request

This object is used to configure all request details.

Property Type Description
Url string Required. The endpoint URL.
Data T The object with data to send in the request body (for POST and PUT).
HeaderType HeaderType The content type (json, xwwwunlercoded, formdata).
Authentication Authentication Object to configure authentication (e.g. Bearer Token).
Cookies string Cookies to send in the request.
Headers HttpHeaders Additional HTTP headers.
AdditionalParams List<KeyValuePair<string, string>> Additional parameters for xwwwunlercoded.

GenericRes<T>: The Response

This object contains the request result.

Property Type Description
Object T The deserialized response object (if the request was successful).
HttpResponse HttpResponseMessage The original HTTP response.
Error ErrorDetails Error details (if the request failed).
Cookies string The cookies received in the response.
IsSuccess bool Indicates if the request was successful (true/false).

Example: GET Request

// Define the expected response model
public class User
{
    public int Id { get; set; }
    public string Name { get; set; }
}

// Make the request
var response = await ApiReq.Instance.Get<User>("https://api.example.com/users/1");

if (response.IsSuccess)
{
    User user = response.Object;
    // ... use the 'user' object
}
else
{
    // ... handle the error with response.Error
}

Example: POST Request

// Define the request model
public class CreateUserInput
{
    public string Name { get; set; }
    public string Email { get; set; }
}

// Define the response model
public class CreateUserOutput
{
    public int Id { get; set; }
    public string CreatedAt { get; set; }
}

// Prepare the request
var requestData = new CreateUserInput { Name = "John Doe", Email = "john.doe@example.com" };
var request = new GenericReq<CreateUserInput>
{
    Url = "https://api.example.com/users",
    Data = requestData,
    HeaderType = HeaderType.json // or xwwwunlercoded, formdata
};

// Make the request
var response = await ApiReq.Instance.Post<CreateUserInput, CreateUserOutput>(request);

if (response.IsSuccess)
{
    CreateUserOutput newUser = response.Object;
    // ...
}

License

This project is under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SweetMeSoft.Connectivity:

Package Downloads
SweetMeSoft.Mobile.Base

SweetMeSoft Mobile MAUI Base Library is a compilation of different utils for MAUI apps

SweetMeSoft.Uno.Base

SweetMeSoft Uno Base Library is a compilation of different utils for UNO Platform apps

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.10.130 101 2/19/2026
1.10.129 466 9/17/2025
1.10.128 543 2/20/2025
1.10.127 245 1/30/2025
1.10.126 322 8/22/2024
1.10.125 262 7/23/2024
1.10.124 292 7/23/2024
1.10.123 250 7/19/2024
1.10.122 340 5/20/2024
1.10.121 485 3/2/2024
1.10.120 279 2/12/2024
1.10.119 270 2/8/2024
1.10.118 311 11/23/2023
1.10.116 233 11/3/2023
1.10.115 254 9/14/2023
1.10.114 283 8/25/2023
1.10.113 294 8/23/2023
1.10.112 245 8/22/2023
Loading failed