Forum Discussion

MarshallArts's avatar
MarshallArts
Experienced User
3 years ago

Communication Error on first data retrieval from cloud

I have built an app for a client which does some custome reporting out of the MYOB data.  It has been working fine for several years with their company file n their own server, but they have recently moved it to the cloud and I am working my way through the process of making ot work there.  The app is built in Visual Studio using VB.NET and the .NET suite of MYOB objects.  I have got to the point where the user can log on, and I can retrieve the necessary tokens etc to authenticate them and establish the connection.  I can retrieve a list of available company files, and I show the list to the user and allow selection of the required one (there is in fact only 1).  I save the selected one into a global CompanyFile variable for use in the rest of the app.  The credentials I specify for the cloud calls are the same ones used to log in to MYOB at the start of the process.  All goes well until I make my first request that tries to retrieve data from the company file, which attempts to get the AccountingParameters for the company file.  This is the first time the Credentials object is used, and the request fails with "Encountered a communication error" exception, which is not very helpful in identifying what is actually wrong. However, the inner exception is a "401 Unauthorised", which seems to suggest that my login does not have the right permissions.  This seems unlikely, as it is an administrator for the company file.  So does anyone know what could be causing this?

  • Han-Solo's avatar
    Han-Solo
    MYOB Moderator

    HI MarshallArts

     

    Thanks for reaching out, If you are getting the error 401 Unauthorized we find the main reason that would break this connection and return the error 401 Unauthorized Is if the client has enabled SSO (Single sign on) from the front end of the program. When the client enables SSO this means they only need to log into the AccountRight file using their my.myob email and password and the username and password is now linked and not required. From an API point of view, if the client enabled SSO we no longer need to pass the x-myobapi-cftoken header. A good way to test this is to remove the header and complete a request.

     

    If this did not resolve the issue then we would be looking to see if the client had updated their password. Here is a support note with some more information on SSO https://apisupport.myob.com/hc/en-us/articles/360001479716-Single-Sign-on-SSO-and-cftoken

     

    To disable SSO the customer would need to log into the company file and go to Setup >> User Access > Select username > untick the box on the top left to link to My.MYOB.