Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

IOrganizationService is returning null

Posted on by 5

I am always getting null value from the IOrganizationService i am using version 9 i using securtiy protocol also below is my code 

IOrganizationService service = null;
string contactid = "0";
string crmAddress = ConfigurationManager.AppSettings["ServiceURL"];
string userName = ConfigurationManager.AppSettings["UserName"];
string pwd = ConfigurationManager.AppSettings["Password"];


//M1
//IOrganizationService service;
//ClientCredentials clientCredentials = new ClientCredentials();
//clientCredentials.UserName.UserName = "svc_crm@investmauritius.com";
////clientCredentials.UserName.Password = "CRM@EDB*2018";
//clientCredentials.UserName.Password = "CRM@EDB*2020";
//// For Dynamics 365 Customer Engagement V9.X, set Security Protocol as TLS12
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
//// Get the URL from CRM, Navigate to Settings -> Customizations -> Developer Resources
//// Copy and Paste Organization Service Endpoint Address URL
//service = (IOrganizationService)new OrganizationServiceProxy(new Uri(@"">edbmauritius1.crm4.dynamics.com"), null, clientCredentials, null);


//M2
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var connectionString = @"AuthType = Office365; Url = " + crmAddress + ";Username=" + userName + ";Password=" + pwd;
CrmServiceClient conn = new CrmServiceClient(connectionString);
//IOrganizationService service;
service = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans