TransWikia.com

Extend /sitecore/api/ssc/EXM/Message with additional data

Sitecore Asked by Mkress on August 23, 2021

I want to extend /sitecore/api/ssc/EXM/Message endpoint with additional data.

I added a new class

namespace Exm.Extended
{
    [ServicesController("EXM.Message")]
    public class MessageController : Sitecore.EmailCampaign.Server.Controllers.Message.MessageController
    {
        //

        //private ParentController _parent;
        public MessageController(
            ItemUtilExt itemUtil,
            ILanguageRepository languageRepository,
            IMessageVariantsService messageVariantsService,
            ILogger logger,
            IExmCampaignService exmCampaignService)

            : base(itemUtil, languageRepository, messageVariantsService, logger, exmCampaignService)
        {
           
        }

       
        [ActionName("DefaultAction")]
        public new Response Message( MessageContext data )
        {
            MessageResponse response = (MessageResponse) base.Message(data);
           //todo change/extend response
            return response;
        }
    }
}

I added a custom DI configurator

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <services>
      <configurator type="EXM.Custom.Configurator, My.Website"/>
...

and Replaced the default EXM MessageController with my custom one

 public void Configure(IServiceCollection serviceCollection)
 {
container.Replace(ServiceDescriptor.Transient(typeof(Sitecore.EmailCampaign.Server.Controllers.Message.MessageController), typeof(Exm.Extended.MessageController)));
..

if I debug now, the custom.messagehandler constructor is hit, but the new default action does never run => still always the Sitecore.EmailCampaign.Server.Controllers.Message.MessageController.Message action.

One Answer

You can take a look at my answer of my question at Is there any way to update the response of a controller action by pipeline process?

It's taken my couple of days to find out this way

Hope it can help

Answered by Tai Vo on August 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP