Forum Discussion
I'm now having issues with the CompanyFileService.GetRange() method. Using:
// Get Company Files var companyFileService = new MYOB.AccountRight.SDK.Services.CompanyFileService(configuration,null,oAuthKeyService); var companyFiles = companyFileService.GetRange();
GetRange() is throwing the following exception:
MYOB.AccountRight.SDK.ApiOperationException: 'Encountered an operation error (https://secure.myob.com/oauth2/account/authorize/)'
Inner Exception:
JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 2, position 1
I'm working in a .NET 6 WPF solution.
Have you got the access token? Hamishjam
I have not used the class that was uploaded by John_Dinning so I cannot comment on whether it works or not but I have built my own class to get the access token
maybe that was why the class was removed from the online sample but like I said I have not tried using it..
If you have the access token then just create a SimpleOAuthKeyService and assign the values from the token to it and you should be able to run the following.
let me know how you get on. If I have time I'll build a test harness and upload it to github for others that are stuck here...seriously considering leaving the .NET SDK and just using RestSharp/HttpClient to access the API
var keystore = new SimpleOAuthKeyService(); keystore.OAuthResponse = new OAuthTokens { AccessToken = myobTokens.AccessToken, ExpiresIn = int.Parse(myobTokens.ExpiresIn), ReceivedTime = myobTokens.TokenTime, RefreshToken = myobTokens.RefreshToken, Scope = myobTokens.Scope, TokenType = myobTokens.TokenType }; // Get Company Files var cfService = new CompanyFileService(configuration, null, keystore); var companies = cfService.GetRange(); foreach (var company in companies) { System.Console.WriteLine(company.Name); Debug.WriteLine(company.Name); }
- Hamishjam3 years agoContributing User
Thanks for the reply kjm. I have the access tokens and I'm passing them into the SimpleOAuthKeyService.OauthResponse. That side of things is fine. I'm just getting exceptions when trying to fetch the companyfile object with the CompanyFileService from the SDK. I suspect there may be some unexpected json or a breaking .NET 6 change that is yet to be addressed. My next step will be to play with it in an old .NET framework and report it via GitHub I guess.
I'm also leaning towards just pulling the JSON old school style but it would be nice to not have to build that out. MYOB is MIA... Developer site is a jungle of 404's.
- kjm3 years agoTrusted Cover User
I am coding in Winforms/.NET 4.8 and it works fine but I am also leaning towards removing the .NET SDK
- John_Dinning3 years agoTrusted User
Hi kjm,
The OAuthLogin.cs and OAuthKeyService.cs files I posted are used in my project, which is WinForms and .NET 4.8.
It's been most of 10 years since I looked at how they work, but they have done all that time for both local, network and cloud company files.
It does seem odd that MYOB have not fixed the broken links and given access to these files. I'm sure it would be to their advantage.
There have been times when I wished that I had not used the SDK, but it did save me a lot of time and a steep learning curve initially and it has been working fine for our purposes.
- Mike_James3 years agoUltimate Cover User
Hi kjm , there have been some recent changes to API support. For developer support, please see https://apisupport.myob.com/hc/en-us/requests/new?ticket_form_id=215283
The email address developers@myob.com has been retired.
Also see https://apisupport.myob.com/hc/en-us/articles/5139088196751-Developer-Update-July-2022 for a summary of changes to API support.
There is no specific statement around online/forum support.
- kjm3 years agoTrusted Cover User
- The_Doc3 years agoUltimate Cover User
Hi kjm
Even though I am a C#.NET, VB.NET programmer I decided long ago NOT to use the SDK - just long experience with MYOB.
I designed my own - using MS Access VBA - and they work almost without problem - but the problem isn't usually the API. And they just work.
However, now I need this code in VC#.NET - hmm guess I got to go for writing my own code in C# - which shouldn't be a problem as the nitty gritty of getting it all working in VBA is long ago worked out.
I get very few API errors - but mainly if I do they are timeouts and I just recycle.
The Doc
Looking for something else?
Search the Community Forum for answers or find your topic and get the conversation started!
Find technical support and help for all MYOB products in our online help centre
Dig into MYOB Academy for free courses, learning paths and live events to help build your business with MYOB.