oauthoffice365dynamics-crmdynamics-crm-2013fetchxml

Moving from Office365 Auth to OAuth


So there's a piece of software using the deprecated Office365 Auth type and I am working to change it. However I cannot seem to get my head around how to edit the following:

            String _fetchxml = getFetch();
         using (CrmServiceClient crmConn = new CrmServiceClient(ConnectionString)
         {
             _crmService = crmConn.OrganizationServiceProxy;
             EntityCollection tn = _crmService.RetrieveMultiple(new FetchExpression(_fetchxml));

This used to work via Office365, but now just throws an Object Reference error.

Could anyone help me figure this out?


Solution

  • The CrmServiceClient implements IOrganizationService, so you can skip the OrganizationServiceProxy and directly use crmConn :

    var tn = crmConn.RetrieveMultiple(new FetchExpression(_fetchxml));

    Beyond that, maybe check the version of the Xrm.Tooling NuGet package you're using. If it's not the latest, you might want to update.