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
- Downloaded the API Sample Solution, these can be found here.
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:
- Right clicking on the folder
- Click on Properties and untick the Read-only box
- Click Apply. You will be presented with this screen:
- Click OK
- Then OK to get back to the folder
- Double click on the APISamples folder
- Then double click on the APISamples.sln file
- This will open in Visual Studio or your default IDE
Configure the APISampleWinFormsApp
- In Solution Explorer, right click on the APISampleWinFormsApp solution and left click on Set as Startup Project.
- Expand the solution tree and click on APIClientFactory.cs. The class should open in your main window.
- Go to the CreateNew() method.
- 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/
- Change the apiClient.SubscriptionKey to either your primary or secondary keys from the Developer Portal.
- Click on the AuthenticationProviderFactory class
- 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
- In Solution Explorer, right click on the APISampleWebSite solution and left click on Set as Startup Project.
- Expand the solution tree, open the Infrastructure folder and click on APIClientFactory.cs
- Go to the CreateNew() method.
- 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/
- Change the apiClient.SubscriptionKey to either your primary or secondary keys from the Developer Portal.
- Go to Settings.cs. Change the ClientID and ClientSecret to the Client ID and Client Secret you have been provided by Sage.
- Right click on the APISampleWebSite project and left click on Properties.
- Click on the Web tab that appears in the properties screen.
- 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
- Click on Create Virtual Directory. You will receive a confirmation message that the virtual directory was successfully created.
- Open Startup.cs and make sure the BaseUri property matches your Project URL.
You will now be able to successfully run the APISampleWebSite solution.