/api/sitecore MVC route alternative for 8.2+

I never realised (until today) that the "api/sitecore/{controller}/{action}" route was a custom Speak route, and recently came across this article which mentioned it was deprecated. Now that 8.2 is out it appears that this route is no longer present (at least in config, I haven't verified through code yet).

Is there a new route / recommended approach for calling controller methods directly now? This was a really handy MVC route, and having the logic live in a Web API controller (even if it is SSC) method means you lose access to the Tracker and other useful functionality.

Obviously I could just map the same route, I was just wondering if anyone knew of a recommended approach; I figured it was being deprecated for a reason.  Thanks!

  • I am able to make custom ajax call by "api/sitecore/{controller}/{action}" in Sitecore 8.2 . Did you get chance to verify through code?
  • In reply to DHEER RAJPOOT:

    Hi Dheer,

    Are you able to make a custom route as "api/{controller}/{action}"? This would be an indicate that sitecore actually deprecated custom Speak route. Its a pain because "api/{controller}/{action}" is standard for custom routes and not "api/sitecore/{controller}/{action}".


    Thanks,


    Carl
  • You can also try below JS code to call controller and action method -

    $.ajax({
    url: window.location.href,
    type: "POST",
    context: this,
    data: { scController: "ControllerName", scAction: "Action Name", myData: datasource },
    success: function (data) {
    //TODO:
    }
    },
    error: function (data) {
    console.log("error", data);
    }
    });
  • In reply to DHEER RAJPOOT:

    You're right Dheer, the route is still there. Since it's not in the config, I'm very curious where they've moved it to, and whether it's still deprecated...
  • In reply to Jason Woods:

    Hi Jason,

    Sorry for late revert. I have not find out where this route has been moved. Did you get a chance to look into it?