We have c# project with .Net Framework 4.6.2 that makes a connection with Dynamics365 using CrmServiceClient to fetch/update data.
I tried both connectionstring as supplying parameters.
I upgraded to the latest NugetPackage for Xrm.Tooling
The majority of the time the code works fine, but about 10% of the time an eror is received.
The error I get (no inner exception): "One or more errors occurred. => Unauthorized Http Status Code (401) was expected in the response: Unknown error => A task was canceled.ERROR REQUESTING Token FROM THE Authentication context - General ADAL Error
Unauthorized Http Status Code (401) was expected in the response: Unknown error => A task was canceled.Unable to connect to CRM: A task was canceled.
Unauthorized Http Status Code (401) was expected in the response: Unknown error => A task was canceled.Unable to Login to Dynamics CRM
Unable to Login to Dynamics CRM"
Originally we thought this was due to issue with our capacity limitations. Both currently we are within our capacity limits, and are still facing the issue.
Anyone any suggestions on what might be the cause?
The code we use:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
//CrmServiceClient serviceTarget = new CrmServiceClient(connectionString);
CrmServiceClient serviceTarget = new CrmServiceClient(new Uri(organizationUrl), applicationID, clientSecret,true,"");
if ((serviceTarget.LastCrmError != null) && (serviceTarget.LastCrmError.Length > 0))
