Skip to content
Developerhome

Using the API Sample Solution

  Less than to read

This guide will help you in getting set up with the API Sample Solution found on our Developer help files here.

Pre-requisites

  • You have received your Cloud ID credentials after submitting this form to Developer Services.
  • You have an active API connection already configured. You can confirm this by testing the API Test Tool here
    • Steps on how to do this in Sage 200 Professional can be found here
    • Steps on how to do this in Sage 200 Standard can be found here
  • Downloaded the API Sample Solution, these can be found here.
:

Caution: Please note that Developer Services do not support the set up and configuration of the Sage 200 API. If you have any issues, please speak to your Sage Business Partner and review Sage 200 API setup and responsibilities.


Using API Sample Solution

Setup APISample

Once you have downloaded and extracted the folders from the APISample zip file, you will need to remove the read only flags from the files in the folder.

This can be done by:

  1. Right clicking on the folder
  2. Click on Properties and untick the Read-only box
  3. Click Apply. You will be presented with this screen: API Sample Properties
  4. Click OK
  5. Then OK to get back to the folder
  6. Double click on the APISamples folder
  7. Then double click on the APISamples.sln file
  8. This will open in Visual Studio or your default IDE

Configure the APISampleWinFormsApp

:

Note: The APISampleWinFormsApp is only to be used if you have requested desktop credentials.

  1. In Solution Explorer, right click on the APISampleWinFormsApp solution and left click on Set as Startup Project.
  2. Expand the solution tree and click on APIClientFactory.cs. The class should open in your main window.
  3. Go to the CreateNew() method.
  4. To make sure you are targeting the correct endpoints, change the apiClient.BaseUrl to either of the following:
    • Sage 200 Standard - https://api.columbus.sage.com/uk/sage200/accounts/
    • Sage 200 Professional - https://api.columbus.sage.com/uk/sage200extra/accounts/
  5. Change the apiClient.SubscriptionKey to either your primary or secondary keys from the Developer Portal.
  6. Click on the AuthenticationProviderFactory class
  7. Change the _provider.ClientID to your Client ID provided by Sage.

You will now be able to run the APISampleWinFormsApp solution successfully.

Configure the APISampleWebSite

:

Note: The APISampleWebSite is only to be used if you have requested web credentials. If you are using local development, you must have a redirect URL set up that ends in /callback. This is only required when using the APISampleWebSite solution for testing purposes or as part of your own project.

  1. In Solution Explorer, right click on the APISampleWebSite solution and left click on Set as Startup Project.
  2. Expand the solution tree, open the Infrastructure folder and click on APIClientFactory.cs
  3. Go to the CreateNew() method.
  4. To make sure you are targeting the correct endpoints, change the apiClient.BaseUrl to either of the following:
    • Sage 200 Standard - https://api.columbus.sage.com/uk/sage200/accounts/
    • Sage 200 Professional - https://api.columbus.sage.com/uk/sage200extra/accounts/
  5. Change the apiClient.SubscriptionKey to either your primary or secondary keys from the Developer Portal.
  6. Go to Settings.cs. Change the ClientID and ClientSecret to the Client ID and Client Secret you have been provided by Sage.
  7. Right click on the APISampleWebSite project and left click on Properties.
  8. Click on the Web tab that appears in the properties screen.
  9. Change the Project URL to your localhost address as specified when you submitted your credentials.
    • For example, if you submitted https://localhost:44320/callback, your project URL would be https://localhost:44320
  10. Click on Create Virtual Directory. You will receive a confirmation message that the virtual directory was successfully created.
  11. Open Startup.cs and make sure the BaseUri property matches your Project URL.
:

Note: There is a redirectUri string that formats your BaseUri and appends “/callback”; to create your full redirect URL. This must exist as part of your credentials, otherwise this will not work.

You will now be able to successfully run the APISampleWebSite solution.