We are adding contact on Email subscription.

IClientApiService _clientApiService = ServiceLocator.ServiceProvider.GetService<IClientApiService>();
_clientApiService.UpdateListSubscription(new UpdateListSubscriptionMessage()
    ListSubscribeOperation = ListSubscribeOperation.Subscribe,
    ContactIdentifier = contact.Identifiers.FirstOrDefault(),
    MessageId = Guid.Parse(id),
    ManagerRootId = Guid.Parse(managerRootId),
    RequireSubscriptionConfirmation = true,

However, this code is working fine on Standalone role but when we are using this code on CM role then we are getting null in _clientApiService and it is throwing an error.

I am using Sitecore version 9.1.1.

  • Hi, it must be because the service is defined in Sitecore.EmailCampaign.Cd.dll that does not exist on your CM. May 20, 2021 at 7:34
  • I have set CM role in web.config at my local and getting the same issue. It is working fine for standalone at my local. Is there any setting at local for Sitecore.EmailCampaign.Cd.dll for CM role ?
    – User7864
    May 20, 2021 at 7:44

1 Answer 1


It's because, the registration of IClientApiService is in the \App_Config\Sitecore\EmailExperience\Sitecore.EmailExperience.ContentDelivery.config file which has a role constraint - role:require="Standalone or ContentDelivery". The following lines are responsible to register the IClientApiService (and some others):

    <!-- Configurator used by EXM to register required services -->
    <configurator type= "Sitecore.EmailCampaign.Cd.DependencyInjection.CustomServiceConfigurator, Sitecore.EmailCampaign.Cd"/>

If you need this on CM, you need to patch this configuration by using the ContentManagement role.

  • One question here , Do I need to patch Sitecore.EmailExperience.ContentDelivery.config file on same path `\App_Config\Sitecore\EmailExperience` ?
    – User7864
    May 20, 2021 at 10:03
  • No, you should able to patch in the \App_Config\Include folder. May 20, 2021 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.