I have an application running on Sitecore 7.5 where my code is invoking an MVC Action at client side. The action method is decorated with the [HttpPost] attribute.
https://www.XYZ.com/api/sitecore/TestController/PostTestAction
As per the John West's post (https://www.sitecore.net/company/blog/386/the-mystery-of-the-sitecoreactioninvoker-3355_, an HTTP request for an action that does not exist results in exception details in the response such as the following:
8704 08:36:00 ERROR Application error. Exception: System.InvalidOperationException Message: Could not invoke action method: PostTestAction. Controller name: TestController. Controller type: XYZ.TestController Source: Sitecore.Mvc at Sitecore.Mvc.Controllers.SitecoreActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) at System.Web.Mvc.Controller.<>c__DisplayClass22.b__1e() at System.Web.Mvc.Async.AsyncResultWrapper.<.cctor>b__0(IAsyncResult asyncResult, Action action) at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at Sitecore.Mvc.Routing.RouteHttpHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
In my case, however this error is intermittent. As the website is always available, it is highly unlikely that the API endpoints are not accessible. This action definitely exists and does what its supposed to do more often than not for the end users. Only the intermittent failures responds with the ASP.NET 404 page not found to the end user.
I have been checking the server logs but couldn't figure out a reason why this action shall execute one time and not another. The windows server logs doesn't show any sporadic network failure or latency at all.
Only thing I can relate to is the post: (https://stackoverflow.com/questions/38761739/sitecore-ajax-post-could-not-invoke-action-method) Again it seems highly unlikely but seems like SitecoreActionInvoker randomly misses executing the 'POST' action.
Appreciate the troubleshooting tips here.
/api/sitecoreroute should not be available on CD instances because it is for CM.