Forum Discussion

smagar's avatar
3 years ago

401 Unauthorized error

Hi, I am able to access my company file however, I am getting "401 Unatuthorized" when trying to get customer details. I am using MYOB SDK and passing my user credentials and request as below

var credential = new CompanyFileCredentials("{myusername}", "{mypassword}");
var response = await customerService.GetRangeAsync(companyFile, "", credential);

Please note, oauth is working and I can access my company file.

 

Request URI generated by above code as below

"https://arl2.api.myob.com/accountright/{companyID}/Contact/Customer/?"

 

I have tried many different options as well, such as

Username: "" Password: ""

 

Moreover, I can access my file online using app.myob but I can't see in AccountRight desktop app. I can see only Sandbox.

 

Any help will be much appriciated.

Thanks

Shiva

  • kjm's avatar
    kjm
    Trusted Cover User

    lot of info missing here

     

    Are you using online or network? I assume because you refer to oauth you are trying to connect online but it looks like you you ar etring to connect to a network file using username/password

     

    if so you are not access the service correctly. You need to pass the token from the oauth call into the contructor of the service. 

     

    Read the dev doco Authentication (myob.com)