Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

CRM : trouble with OrganizationWebProxyClient object always null

Posted on by Microsoft Employee

Hello guys,

We are using "Microsoft.Xrm.Tooling.Connector" to connect a custom ticketing portal to CRM. Below is the code used to connect. 

The IOrganizationService object is always null. 

string CrmUrl = System.Configuration.ConfigurationManager.AppSettings["CrmServerUrl"];
string CrmOrgname = System.Configuration.ConfigurationManager.AppSettings["CrmOrgName"];
string CrmUserName = System.Configuration.ConfigurationManager.AppSettings["CrmUsername"];
string CrmPassWord = System.Configuration.ConfigurationManager.AppSettings["CrmPassword"];
string sDomain = System.Configuration.ConfigurationManager.AppSettings["CrmDomain"];


CrmServiceClient conn = new CrmServiceClient("Url=" + CrmUrl + "; Username=" + CrmUserName + "; Password=" + CrmPassWord + "; AuthType=Office365");
organizationservice = conn.OrganizationWebProxyClient != null ? conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;

Does anyone is aware of a solution to this?

Thanks

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: CRM : trouble with OrganizationWebProxyClient object always null

    Hi ,

    Can you please add below line above line "CrmServiceClient conn = new CrmServiceClient"

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM : trouble with OrganizationWebProxyClient object always null

    Thanks for the quick help shahbaaz indeed the problem came from the value in app config file.

  • Verified answer
    Shahbaaz Ansari Profile Picture
    Shahbaaz Ansari 6,203 on at
    RE: CRM : trouble with OrganizationWebProxyClient object always null

    Also make sure you have set all the value in app config file properly and you are getting all the value when fetching it from app config

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    Shahbaaz Ansari 6,203 on at
    RE: CRM : trouble with OrganizationWebProxyClient object always null

    Hi MatB,

    Please try below code and let me know if you still face issue,

    string CrmUrl = System.Configuration.ConfigurationManager.AppSettings["CrmServerUrl"];

    string CrmOrgname = System.Configuration.ConfigurationManager.AppSettings["CrmOrgName"];

    string CrmUserName = System.Configuration.ConfigurationManager.AppSettings["CrmUsername"];

    string CrmPassWord = System.Configuration.ConfigurationManager.AppSettings["CrmPassword"];

    string sDomain = System.Configuration.ConfigurationManager.AppSettings["CrmDomain"];

    ClientCredentials creadentials = new ClientCredentials();

    creadentials.UserName.UserName = CrmUserName;

    creadentials.UserName.Password = CrmPassWord;

    creadentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;

    Uri organization = new Uri(CrmUrl);

    Uri Homeuri = null;

    using (OrganizationServiceProxy serviceproxy = new OrganizationServiceProxy(organization, Homeuri, creadentials, null))

    {                  

    service = (IOrganizationService)serviceproxy;

                   }

    If you find it helpful, Please Mark My Answer as Verified.

    Best Regards,

    Shahbaaz

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans