ConnectWise.Http 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package ConnectWise.Http --version 1.0.5
NuGet\Install-Package ConnectWise.Http -Version 1.0.5
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="ConnectWise.Http" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ConnectWise.Http --version 1.0.5
#r "nuget: ConnectWise.Http, 1.0.5"
#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.
// Install ConnectWise.Http as a Cake Addin
#addin nuget:?package=ConnectWise.Http&version=1.0.5

// Install ConnectWise.Http as a Cake Tool
#tool nuget:?package=ConnectWise.Http&version=1.0.5

ConnectWise.Http

A .Net HttpClient wrapper for interacting with the ConnectWise Manage REST API.

Installation

NuGet PM> Install-Package ConnectWise.Http

Usage

Client Setup

using ConnectWise.Http;

// Create Settings
var settings = new CWApiSettings(
  "https://cw.siteurl.com",
  "companyName",
  new MemberAuthSettings("publicKey", "privateKey")
  );

// Create HTTP Client
var client = new CWHttpClient(settings);

GET Request

using ConnectWise.Http.Modules.Service;

// Build & Send Request
int ticketId = 121;
var request = ServiceModule.Tickets.GetRequest(ticketId);
var response = await client.SendAsync(request);

POST/PUT Request

You serialize the body content before building the request.

// Build & Send Request
string serializedContent = JsonConvert.SerializeObject(...);
var request = ServiceModule.Tickets.CreateRequest(serializedContent);
var response = await client.SendAsync(request);

PATCH Request

ConnectWise.Http provides a ConnectWise Patch Operation object as per their REST developer documentation.

// List Patch Operations
var operations = new List<CWPatch>();
operations.Add(new CWPatch {
  Op = CWPatchOperation.Replace,
  Path = "status/name",
  Value = "Closed"
  });
  
// Build & Send Request
int ticketId = 121;
var request = ServiceModule.Tickets.UpdateRequest(ticketId, operations);
var response = await client.SendAsync(request);

Deserialization

ConnectWise.Http can also attempt to deserialize the response into your provided type.

// Where "TConnectWiseTicket" is your custom type.
int ticketId = 121;
TConnectWiseTicket ticket = null;
var request = ServiceModule.Tickets.GetRequest(ticketId);
var response = await client.SendAsync<TConnectWiseTicket>(request);
if (response.IsSuccessful && response.IsDeserialized) ticket = response.Data;

Modules

Below are the modules currently implemented. You can use the CWRequest object to specify specific endpoints not yet supported here - These serve only to simplify the creation of the request URI.

Modules Supported
Company Yes
Expense Yes
Finance No
Marketing No
Procurement No
Project Yes
Sales No
Schedule Yes
Service Yes
System No
Time Yes
Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 18,363 8/22/2019
1.1.0 1,381 7/14/2019
1.0.9 2,457 10/1/2018
1.0.8 1,795 5/24/2018
1.0.7 1,734 5/24/2018
1.0.6 1,693 5/22/2018
1.0.5 1,781 4/30/2018
1.0.4 1,859 4/27/2018
1.0.3 1,666 4/26/2018
1.0.2 2,022 12/10/2017
1.0.0.1 1,715 11/22/2017
1.0.0 1,787 11/22/2017

Finished CompanyModule and fully completed ExpenseModule. Added Search endpoint to Tickets with ServiceModule.