Forum Discussion
So my question remains: using the .NET SDK and the Service objects within it, once I am authenticated and have the businessId value, how do I request data via the Service objects? All the Get and GetRange calls on these objects require a CompanyFile object as their first parameter. So how can I obtain or create a CompanyFile object corresponding to the businessId? I can see no way to do this. I am using the latest version of the SDK, version 2025.5.658.
Finally, I have an answer. It is necessary to create your own instance of a CompanyFile object in code, rather than getting it via the (soon to disappear) CompanyFile Service. So, after authentication is complete and you have your businessId value, the following steps (in C#) worked for me:
- Make a Guid object, and populate it. myBusinessID is the string value of the business ID
Guid myCFGuid = Guid.Parse(myBusinessID); - Declare a CompanyFile object, and create the instance
CompanyFile myCompany;
myCompany = new CompanyFile {
Id = myCFGuid,
Uri = new Uri($"https://api.myob.com/accountright/{myCFGuid}")
};
This code creates the CompanyFile instance, and initialises the Id and Uri members.
That appears to be all that is required. You could also collect the Business Name and set that if you wanted.
This CompanyFile object can then be used as the first parameter to the Get/GetRange calls to the various Service objects that request data from the MYOB cloud. And the other calls for updating etc no doubt. So simple once you see it. I hope this might save someone else the hours I have burnt trying to figure this out.
Looking for something else?
Search the Community Forum for answers or find your topic and get the conversation started!
Learn, solve, grow
Level up your skills and find answers across all MYOB products