SMEAppHouse.Core.RestSharpClientLib 9.0.9

dotnet add package SMEAppHouse.Core.RestSharpClientLib --version 9.0.9
                    
NuGet\Install-Package SMEAppHouse.Core.RestSharpClientLib -Version 9.0.9
                    
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="SMEAppHouse.Core.RestSharpClientLib" Version="9.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SMEAppHouse.Core.RestSharpClientLib" Version="9.0.9" />
                    
Directory.Packages.props
<PackageReference Include="SMEAppHouse.Core.RestSharpClientLib" />
                    
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 SMEAppHouse.Core.RestSharpClientLib --version 9.0.9
                    
#r "nuget: SMEAppHouse.Core.RestSharpClientLib, 9.0.9"
                    
#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 SMEAppHouse.Core.RestSharpClientLib@9.0.9
                    
#: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=SMEAppHouse.Core.RestSharpClientLib&version=9.0.9
                    
Install as a Cake Addin
#tool nuget:?package=SMEAppHouse.Core.RestSharpClientLib&version=9.0.9
                    
Install as a Cake Tool

SMEAppHouse.Core.RestSharpClientLib

Overview

SMEAppHouse.Core.RestSharpClientLib is an extension wrapper library for using the RestSharp package. It provides a simplified API client interface and utilities for making HTTP requests.

Target Framework: .NET 8.0
Namespace: SMEAppHouse.Core.RestSharpClientLib


Public Classes and Interfaces

1. IApiAccessor (Interface)

Interface for API access operations.

Namespace: SMEAppHouse.Core.RestSharpClientLib

Methods
ApiResponse<T> CallApi<T>(string path, Method method, List<KeyValuePair<string, string>> queryParams, object postBody, Dictionary<string, string> headerParams, Dictionary<string, string> formParams, Dictionary<string, FileParameter> fileParams, Dictionary<string, string> pathParams, string contentType)

2. ApiClient (Class)

Main client class for making API requests using RestSharp.

Namespace: SMEAppHouse.Core.RestSharpClientLib

Properties
  • Configuration Configuration - Client configuration
  • string BasePath - Base URL for API requests
Methods
public ApiResponse<T> CallApi<T>(string path, Method method, ...)
public string ParameterToString(object obj)
public string SelectHeaderContentType(string[] contentTypes)
public string SelectHeaderAccept(string[] accepts)
public string EscapeString(string str)
Usage Example
using RestSharp;
using SMEAppHouse.Core.RestSharpClientLib;

var client = new ApiClient
{
    BasePath = "https://api.example.com"
};

var response = client.CallApi<Product>(
    "/products/1",
    Method.Get,
    queryParams: null,
    postBody: null,
    headerParams: null,
    formParams: null,
    fileParams: null,
    pathParams: null,
    contentType: "application/json"
);

if (response.StatusCode == 200)
{
    var product = response.Data;
    Console.WriteLine($"Product: {product.Name}");
}

3. ApiResponse<T> (Class)

Represents an API response with data and status information.

Namespace: SMEAppHouse.Core.RestSharpClientLib

Properties
  • int StatusCode - HTTP status code
  • Dictionary<string, string> Headers - Response headers
  • T Data - Response data
  • string ErrorText - Error message if any
Usage Example
var response = client.CallApi<List<Product>>("/products", Method.Get, ...);

if (response.StatusCode == 200)
{
    foreach (var product in response.Data)
    {
        Console.WriteLine(product.Name);
    }
}
else
{
    Console.WriteLine($"Error: {response.ErrorText}");
}

4. ApiException (Class)

Exception thrown for API errors.

Namespace: SMEAppHouse.Core.RestSharpClientLib

Properties
  • int ErrorCode - Error code
  • string ErrorContent - Error content
Usage Example
try
{
    var response = client.CallApi<Product>(...);
}
catch (ApiException ex)
{
    Console.WriteLine($"API Error {ex.ErrorCode}: {ex.ErrorContent}");
}

5. Configuration (Class)

Configuration for API client.

Namespace: SMEAppHouse.Core.RestSharpClientLib

Properties
  • string BasePath - Base URL
  • int Timeout - Request timeout in milliseconds
  • string UserAgent - User agent string
  • Dictionary<string, string> DefaultHeaders - Default headers
Usage Example
var config = new Configuration
{
    BasePath = "https://api.example.com",
    Timeout = 30000,
    DefaultHeaders = new Dictionary<string, string>
    {
        { "Authorization", "Bearer token123" }
    }
};

var client = new ApiClient { Configuration = config };

6. IReadableConfiguration (Interface)

Interface for readable configuration.

Namespace: SMEAppHouse.Core.RestSharpClientLib


7. GlobalConfiguration (Class)

Global configuration singleton.

Namespace: SMEAppHouse.Core.RestSharpClientLib

Usage Example
GlobalConfiguration.Instance.BasePath = "https://api.example.com";
GlobalConfiguration.Instance.Timeout = 30000;

8. ExceptionFactory (Delegate)

Delegate for creating exceptions from API responses.

Namespace: SMEAppHouse.Core.RestSharpClientLib


Complete Usage Examples

Example 1: GET Request

using RestSharp;
using SMEAppHouse.Core.RestSharpClientLib;

var client = new ApiClient
{
    BasePath = "https://jsonplaceholder.typicode.com"
};

var response = client.CallApi<List<Post>>(
    "/posts",
    Method.Get,
    queryParams: null,
    postBody: null,
    headerParams: null,
    formParams: null,
    fileParams: null,
    pathParams: null,
    contentType: "application/json"
);

if (response.StatusCode == 200)
{
    foreach (var post in response.Data)
    {
        Console.WriteLine($"{post.Id}: {post.Title}");
    }
}

Example 2: POST Request

var newPost = new Post
{
    Title = "New Post",
    Body = "Post content",
    UserId = 1
};

var response = client.CallApi<Post>(
    "/posts",
    Method.Post,
    queryParams: null,
    postBody: newPost,
    headerParams: null,
    formParams: null,
    fileParams: null,
    pathParams: null,
    contentType: "application/json"
);

if (response.StatusCode == 201)
{
    Console.WriteLine($"Created post with ID: {response.Data.Id}");
}

Example 3: Request with Headers and Query Parameters

var queryParams = new List<KeyValuePair<string, string>>
{
    new KeyValuePair<string, string>("userId", "1")
};

var headerParams = new Dictionary<string, string>
{
    { "Authorization", "Bearer token123" },
    { "X-API-Key", "key456" }
};

var response = client.CallApi<List<Post>>(
    "/posts",
    Method.Get,
    queryParams: queryParams,
    postBody: null,
    headerParams: headerParams,
    formParams: null,
    fileParams: null,
    pathParams: null,
    contentType: "application/json"
);

Dependencies

  • RestSharp (v112.1.0)
  • Newtonsoft.Json

Notes

  • Wraps RestSharp for simplified API access
  • Provides typed responses
  • Supports all HTTP methods
  • Includes error handling
  • Configurable timeouts and headers

License

Copyright © SME App House 2025

Product 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.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SMEAppHouse.Core.RestSharpClientLib:

Package Downloads
SMEAppHouse.Core.GHClientLib

GraphHopper Extension Library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.9 117 11/29/2025
9.0.8 119 11/29/2025
9.0.7 123 11/29/2025
1.4.1906.15 830 6/12/2019
1.4.1906.14 748 6/9/2019
1.4.1811.9 1,065 11/9/2018
1.3.18073.3 1,002 11/6/2018

release notes