Forum Discussion
Hi eJulia
The article jumps between Vb & C# - but there is a bit in there about 'Use the WebRequest class" which is what the MYOB SDK uses to make their call - and where it scrambles in their code.
I am now just coming up for air after getting all my clients back online - ALL are MS Access databases - the 1st one in which I panicked I converted to AntView2 - then quietly analysed things and realised the problem WASN'T the browser - the rest I have left on the std MS Access WebBrowser and altered my code ( the fixes were minor in essence) - .. .all are back online and running perfectly.
I found a very old version of the old VB.NET utility MYOB rolled out in about 2013 ( they also had a VC#.Net version) - that emulates the process of getting data from a clients database.
It was built initially for local based datafiles which was very common 2013 and few were online.
I remember getting the VB version going but not the VC# -but being neither VB or VC# proficient then shelved both and went MS Access from the ground.
Having now proven the browser is a red herring ( which I actually told Tana ( in MYOB API) in the middle of this mess - and MYOB had rolled out the Edge browser fix - no matter which browser I used the returned payload was the same.
Sorry - long story - anyways I have found an old version of the VB.NET utility (2013) Visual Studio 2013) version and converted and updated it to VS 2022 and it is working. The SDK updated fine.
And it hangs as soon as it goes to get the Access Code - web browser pops up exactly the same error as I was getting manually - and it uses the WebRequest Class in VB.NET - and I think this is the problem.
When I re-run - the browser just gives an error and fails to run.
eJulia- the reason you got a jumble back is not a failure - if you read my posts you will gleam why - you are looking at the returned document/Source and yes it is rubbish!!!!! The code you need is no longer embedded in the page returned and this is where I think things have gone wrong - it use to be embedded in a json formatted payload that loaded as a web page = BLANK but by examining the "Document" component returned you could search for "code=" but this is no longer happening - the "Document" method no longer is useful - it is the returned URL title you need and that is where the code is.
POST this in any browser - any EDGE/CHROME/OPERA/FOX -
https://secure.myob.com/oauth2/account/authorize?client_id=[<< developer Id>>]&redirect_uri=http://desktop&response_type=code&scope=CompanyFile
and you will get an access code returned. That is what you need to capture - it gives an error page - and if you right click and examine the source it is gobblety gooch - but before this mess contained the embedded code=....
Your VB, VC# calls now have to examine NOT the returned webbrowser.Document method but the Webbrowser.URL ( or similar) I haven't quite found the method to get your code.
I repeat THE BROWSER TYPE IS IRRELVANT AND I BELIEVE THIS IS A RED HERRING.
In MS Access it use to be
Me.WebView.Object.Document.documentElement.outerHTML
and now is
Me.WebView.Object.Document.URL
Simple - found by trial and error and I believe this will be the anser in VB & VC# - I will let you know my outcome.
The Doc
I already posted the solution for .NET based on The_Doc findings about 9 days ago:
- Change webB.DocumentText to webB.Url.AbsoluteUri
- Replace ExtractSubstring with:
private static string ExtractAuthorizationCode(string uri)
{
var uriObj = new Uri(uri);
var queryParams = HttpUtility.ParseQueryString(uriObj.Query);
return queryParams["code"];
}
I understand finding solutions in these threads is tricky 🙂
- The_Doc3 months agoUltimate Cover User
Hi Steve_PP
Yes thanks - just a lot of info to digest coming up for air after getting all my clients back on line - which, at that stage I was not talking VB/VC and have since loaded the old VB.NET MYOB utility and updated and have had time to concentrate on creating a test solution for all versions - with the view that when MYOB finally roll out the Edge viewer I suspect it won't matter.
Thanks for your reminder - will save me a lot of soul searching - will post as I get success hoping to have VB/VC# and MS Access trial version in prep for any more wild updates by MYOB.
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.