Dear Sage Support,
Good Morning,
Hope everyone is doing great,
I'm having hard time connecting my .NET Application via .NET SDK for Sage50 Accounting.
I have prepared an sample CONSOLE APPLICATION in order to test the authentication as per documentation provided "Sage 50 .NET API - Quick Start Guide.pdf".
See attached Image 1:[01-Initial-Connection.PNG]: As suggested in documentation we can pass BLANK Application ID which will allow us to connect to Sage 50 Sample Companies.
But unfortunately, in my case it didn't happened.
I was getting this error: "Object reference not set to an instance of an object".
Can you please tell me where this are wrong ?
Question: Since I do own as verified Sage50 Accounting software, where do I get APPLICATION ID ?
How can I get APPLICATION ID ?
See attached Image 2:[02-Open-Company-Link.PNG]: I have tried the exact code as mentioned in attached image.
Please see below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sage.Peachtree.API;
namespace Sage50_OMS_ConsoleApp
{
class Program
{
//The main session into the Sage 50 application;
static void Main(string[] args)
{
try
{
PeachtreeSession apiSession = new PeachtreeSession();
AuthorizationResult authResult = new AuthorizationResult();
// The main session into the Sage 50 application;
Company companyContext = null;
// start the session.
// with no application ID, you can only open Sample companies
apiSession.Begin("");
// Get CompanyIdentifer for sample company
CompanyIdentifierList companyId_List = apiSession.CompanyList();
CompanyIdentifier companyId = companyId_List.Find(
delegate (CompanyIdentifier o)
{
return o.CompanyName == "My Company Name";
});
// Ask the Sage 50 application if this application has been granted access to the company.
authResult = apiSession.VerifyAccess(companyId);
// Check if the app has authorization before
if (authResult == AuthorizationResult.Granted)
{
// open the company
companyContext = apiSession.Open(companyId);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString()+Environment.NewLine+ex.InnerException);
}
Console.ReadLine();
}
}
}
See attached Image 3:[03-Sage-City-Link.PNG]
Since I had no clue on how do I resolve this issue. As a result , I logged into Sage City & requesting for any help.
Kindly help me solve the issue as it is staggering my work in my project.
Please let me know if you require any extra information from my end.
Thanks & have a great day ahead.
- Ajay