1

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.

3
  • I am fairly confident that you can't actually do what you are thinking you are trying to do. Question: What are you trying to achieve? Nov 14 '20 at 5:21
  • I have renamed the Controller to CustomMessageController and rewritten the API-Controller-Url in Speak-UI call in JS => but with Sitecore 9.3 that will not work anymore - because of the removed Speak UI in EXM.
    – Mkress
    Nov 16 '20 at 5:54
  • Yeah, that's why I'm asking what you are trying to actually accomplish by doing this. If I understood the use case, there's probably another way to achieve it. Nov 16 '20 at 16:35
-1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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