SweetMeSoft.Connectivity
1.10.129
dotnet add package SweetMeSoft.Connectivity --version 1.10.129
NuGet\Install-Package SweetMeSoft.Connectivity -Version 1.10.129
<PackageReference Include="SweetMeSoft.Connectivity" Version="1.10.129" />
<PackageVersion Include="SweetMeSoft.Connectivity" Version="1.10.129" />
<PackageReference Include="SweetMeSoft.Connectivity" />
paket add SweetMeSoft.Connectivity --version 1.10.129
#r "nuget: SweetMeSoft.Connectivity, 1.10.129"
#:package SweetMeSoft.Connectivity@1.10.129
#addin nuget:?package=SweetMeSoft.Connectivity&version=1.10.129
#tool nuget:?package=SweetMeSoft.Connectivity&version=1.10.129
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
andDELETE
. - Content Handling: Supports
application/json
,application/x-www-form-urlencoded
andmultipart/form-data
. - Generic Classes: Uses
GenericReq<T>
for requests andGenericRes<T>
for responses, allowing strong typing. - Cookie Management: Automatically manages cookies between requests.
- File Download: Includes a
DownloadFile
method to get files as aStreamFile
. - 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 | Versions 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. |
-
.NETStandard 2.1
- Microsoft.AspNet.WebApi.Client (>= 6.0.0)
- Newtonsoft.Json (>= 13.0.4)
- SweetMeSoft.Base (>= 1.10.144)
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.129 | 293 | 9/17/2025 |
1.10.128 | 460 | 2/20/2025 |
1.10.127 | 150 | 1/30/2025 |
1.10.126 | 225 | 8/22/2024 |
1.10.125 | 168 | 7/23/2024 |
1.10.124 | 197 | 7/23/2024 |
1.10.123 | 168 | 7/19/2024 |
1.10.122 | 240 | 5/20/2024 |
1.10.121 | 348 | 3/2/2024 |
1.10.120 | 196 | 2/12/2024 |
1.10.119 | 191 | 2/8/2024 |
1.10.118 | 241 | 11/23/2023 |
1.10.116 | 163 | 11/3/2023 |
1.10.115 | 196 | 9/14/2023 |
1.10.114 | 207 | 8/25/2023 |
1.10.113 | 206 | 8/23/2023 |
1.10.112 | 184 | 8/22/2023 |
1.10.108 | 210 | 8/7/2023 |
1.10.107 | 257 | 6/19/2023 |
1.10.106 | 287 | 6/10/2023 |
1.10.105 | 242 | 5/31/2023 |
1.10.104 | 345 | 2/23/2023 |
1.10.103 | 407 | 12/3/2022 |
1.10.102 | 406 | 12/3/2022 |
1.10.101 | 414 | 11/25/2022 |
1.10.100 | 405 | 11/24/2022 |
1.0.0 | 426 | 11/23/2022 |