Hello everyone,
I have already connected d365 CRM online with the .net core console app using client id, clients secret, and organization URI. But it is throwing an error on connecting with on-prem.
here is the error.
Microsoft.PowerPlatform.Dataverse.Client.Utils.DataverseConnectionException
HResult=0x80131500
Message=Failed to connect to Dataverse
Source=Microsoft.PowerPlatform.Dataverse.Client
StackTrace:
at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient.CreateServiceConnection(Object externalOrgServiceProxy, AuthenticationType requestedAuthType, String hostName, String port, String orgName, NetworkCredential credential, String userId, SecureString password, String domain, String Geo, String claimsHomeRealm, Boolean useSsl, Boolean useUniqueInstance, OrganizationDetail orgDetail, String clientId, Uri redirectUri, PromptBehavior promptBehavior, OrganizationWebProxyClient externalOrgWebProxyClient, String certificateThumbPrint, StoreName certificateStoreName, X509Certificate2 certificate, Uri instanceUrl, Boolean isCloned, Boolean useDefaultCreds, Version incomingOrgVersion, ILogger externalLogger)
at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient..ctor(Uri instanceUrl, String clientId, String clientSecret, Boolean useUniqueInstance, ILogger logger)
at DOHTestCoreConApp.Program.crmConnection() in C:\DOH PRP\Code\DOHTestCoreConApp\DOHTestCoreConApp\Program.cs:line 23
at DOHTestCoreConApp.Program.Main(String[ args) in C:\DOH PRP\Code\DOHTestCoreConApp\DOHTestCoreConApp\Program.cs:line 11
This exception was originally thrown at this call stack:
[External Code
Inner Exception 1:
AggregateException: One or more errors occurred. (Need a non-empty authority (Parameter 'Authority'))
Inner Exception 2:
ArgumentNullException: Need a non-empty authority (Parameter 'Authority')
and here is the code.
string SoapOrgServiceUri = "http://crm/XRMServices/2011/Organization.svc"; Uri serviceUri = new Uri(SoapOrgServiceUri); string client_id = "****"; string client_sec = "****"; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var cdsClient = new ServiceClient(serviceUri, client_id, client_sec, true);
Data8.PowerPlatform.Dataverse.Client has made my day.
Hi,
I have not tried .Net Core SDK with on-premise.
You can try registering your on-premise app first:
docs.microsoft.com/.../walkthrough-register-app-active-directory
Sorry, it is necessary to use .net core. Can't change that.
Hi,
Yes, that is the reason you need to access it using CRMServiceClient (.Net Framework).
You can access an on-premise environment, without registering an App (and using AD (or NTLM) Authentication).
Only Client Secret and OAuth can be used to connect .net core with CRM.
The problem is I don't get redirect URI on registering the app, that's why I am using client secrect and I am using .net core.
Hi,
Thank you for your query.
For On premise, you need to connect using Authentication Type: AD, which is not supported with ServiceClient.
I believe this is meant for only Datavers (Online) version.
For On-premise, you need to use .Net Framework, please look into following article:
Your AD Connection string should be something like:
string url = ; string conn = $@" Url = {url}; AuthType = AD; RequireNewInstance = True";
You can add username and password as well.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156