Skip to content
Developerhome

Sample Solutions and Client Libraries

  Less than to read

The Samples solution demonstrates how to make calls to the API. It also references libraries that simplify using Sage authentication and hide the complexity of making calls to the API via HTTP.

Name C# Download File
Samples solution Download
Client library Download

How to Use the Sample App to Get Up and Running

We provide a sample app which you can use to get up and running quickly.

The sample applications are found in the APISamples.sln file, which contains two projects:

  1. APISampleWebSite
  2. APISampleWinFormsApp

For more information on setting up and download the sample solution, please follow the How to Set Up and Run the Samples

How to Use the API Libraries

Sage provides an API client library to simplify how you interact with a Sage API.
This consists of two DLLs:

APIClientLibrary.dll

The APIClientLibrary.dll has an APIClient class that exposes four methods: GET, PUT, POST, and DELETE. These methods accept parameters as strings and return strings containing the requested data. The APIClient class handles all the heavy lifting for you, such as adding required headers and performing the HTTP interaction with the API.

You do not have to use the APIClientLibrary. If you want to write the details yourself, we provide the source code of the APIClientLibrary so you can see what it does and how it does it.

SageID.PublicClient.dll

The SageID.PublicClient.dll wraps the OAuth authentication used by SageID. The DLL exposes an instance class AuthenticationProvider that you use to authenticate and automatically generate refresh tokens. This instance class can be accessed via the static AuthenticationProviderFactory class.

To use this:

  1. Set the following property on the AuthenticationProviderFactory:
    • For Sage 200 (all versions):
    • _provider.ClientID = "Enter your client ID here";
    • The client ID is specific to your application. You must register to obtain your own unique client ID.
  2. Once you have set up the client ID, call the AuthenticationProviderFactory.GetProvider().GetToken() method to return the SageID token. If an unexpired token is not available, a login screen is displayed.

ou do not have to use the SageID.PublicClient authentication provider. If you want to write the details yourself, we provide the source code of the SageID.PublicClient so you can see what it does and how it does it.

SageID.ConfidentialClient

The < strong>SageID.ConfidentialClient.dll</strong> is no longer required. Instead, make use of Microsoft Owin classes, as shown in the Website Sample.

To use this, you need to:

  1. Set two properties on the Website sample's Startup class:

By following these instructions and utilising the provided samples and client libraries, you can effectively interact with the Sage API and simplify the authentication process.