Forum Discussion

accounts11's avatar
6 years ago

The remote server returned an error: (401) Unauthorized.

Hi,

 

I'm attempting to use api for something as basic as connecting to my api,

 

var configuration = new ApiConfiguration("http://192.168.1.21:8080/AccountRight/c30568dfa-b8ea-4b30-b0f6-d549011abe27");
var credentials = new CompanyFileCredentials("Administrator", "secrete");
var cfService = new CompanyFileService(configuration);

var companyFiles = cfService.GetRange();
var companyfile = companyFiles[0];

 

but I get an error,

 

InnerException = {"The remote server returned an error: (401) Unauthorized."}

 

Message = "Encountered a communication error (http://192.168.1.21:8080/AccountRight/c30568dfa-b8ea-4b30-b0f6-d549011abe27)"

 

at MYOB.AccountRight.SDK.Extensions.ExceptionExtensions.ProcessException(Exception ex, Uri requestUri) in c:\projects\accountright-live-api-net-sdk\MYOB.API.SDK\SDK\Extensions\ExceptionExtensions.cs:line 69
at MYOB.AccountRight.SDK.Services.ServiceBase.MakeApiGetRequestSync[T](Uri uri, ICompanyFileCredentials credentials, String eTag) in c:\projects\accountright-live-api-net-sdk\MYOB.API.SDK\SDK\Services\ServiceBase.cs:line 149
at MYOB.AccountRight.SDK.Services.CompanyFileService.GetRange() in c:\projects\accountright-live-api-net-sdk\MYOB.API.SDK\SDK\Services\CompanyFileService.cs:line 45
at Infrastructure.MYOBHelper.MYOBHelper..ctor() in C:\Portals\ServiceLayer\DakwalJobsServiceApplication\DakwalJobsServiceApplication\Infrastructure\MYOBHelper\MYOBHelper.cs:line 22
at Repository.Repositories.MainContentRepository.GetMainContent(Guid id, Int32 page, Boolean useExcel, String user) in C:\Portals\ServiceLayer\DakwalJobsServiceApplication\DakwalJobsServiceApplication\Repository\Repositories\MainContentRepository.cs:line 2076

 

I've used api's for just about everything else, it's just the myob api's that are not working, and example listed in the SDK is very vague, without much help.

 

Can anyone offer a solution ? Thanks you.

 

 

 

  • CodeMaker's avatar
    CodeMaker
    Contributing User

    One point to mention with: CompanyFileCredentials("Administrator", "secrete");

    Secrete should be the Administrator password, not Secrete.

Looking for something else?

Search the Community Forum for answers or find your topic and get the conversation started!

Community home

Dig into MYOB Academy for free courses, learning paths and live events to help build your business with MYOB.