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

This thread is now closed to new comments.
Some of the links and information provided in this thread may no longer be available or relevant.
If you have a question please start a new post.
accounts11
1 Post
User

1Posts

0Kudos

0Solutions

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.

 

 

 

1 REPLY 1
CodeMaker
Contributing User
6 Posts
Contributing User
Contributing User

6Posts

0Kudos

1Solutions

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

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

Secrete should be the Administrator password, not Secrete.

Didn't find your answer here?

Try using advanced search to find a post more easily Advanced Search
or
Get the conversation started and make a new post Start a Post