/api/sitecore is not working in CD serverWeb API 2 Attribute Routing with Sitecore 8.2 Initial...

Is there a standard definition of the "stall" phenomena?

How can I effectively map a multi-level dungeon?

Is it possible to spoof an IP address to an exact number?

What is the difference between an "empty interior" and a "hole" in topology?

How serious is plagiarism in a master’s thesis?

Are "confidant" and "confident" homophones?

Sleepy tired vs physically tired

When is one 'Ready' to make Original Contributions to Mathematics?

Convert integer to full text string duration

How can a ban from entering the US be lifted?

How do I iterate equal values with the standard library?

Would the Life cleric's Disciple of Life feature supercharge the Regenerate spell?

Does 5e have an equivalent of the Psychic Paper from Doctor Who?

What's the big deal about the Nazgûl losing their horses?

Motorcyle Chain needs to be cleaned every time you lube it?

Do Goblin tokens count as Goblins?

Sci-fi book (no magic, hyperspace jumps, blind protagonist)

Taking advantage when the HR forgets to communicate the rules

Why do most airliners have underwing engines, while business jets have rear-mounted engines?

What is the fundamental difference between catching whales and hunting other animals?

How would a sea turtle end up on its back?

What is the maximum amount of diamond in one Minecraft game?

Does the force of friction helps us to accelerate while running?

How did Captain Marvel do this without dying?



/api/sitecore is not working in CD server


Web API 2 Attribute Routing with Sitecore 8.2 Initial ReleaseSitecore 8.2 - Best way to expose sitecore data to external system as web apiWeb API 404 on content delivery serverDo we have an API for sitecore 6.6Sitecore JSS integrated mode with subsitesloading partial view from jquerySitecore WebApi custom route not working controller not foundServicesApiController in referenced project/DLLWeb Api on Content Delivery server returns unexpected JSON response with __interceptorsSitecore custom api routing is not working






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















Sitecore Version: 9.0.2



Environment: Azure PaaS CD



We are trying to call /api/sitecore/controller/actionname with AJAX. It's working on the CM server but not on the CD server.



I disabled custom errors and removed HTTP error configuration in web.config, but it still redirects to the custom 404 page I've created.










share|improve this question































    1















    Sitecore Version: 9.0.2



    Environment: Azure PaaS CD



    We are trying to call /api/sitecore/controller/actionname with AJAX. It's working on the CM server but not on the CD server.



    I disabled custom errors and removed HTTP error configuration in web.config, but it still redirects to the custom 404 page I've created.










    share|improve this question



























      1












      1








      1








      Sitecore Version: 9.0.2



      Environment: Azure PaaS CD



      We are trying to call /api/sitecore/controller/actionname with AJAX. It's working on the CM server but not on the CD server.



      I disabled custom errors and removed HTTP error configuration in web.config, but it still redirects to the custom 404 page I've created.










      share|improve this question
















      Sitecore Version: 9.0.2



      Environment: Azure PaaS CD



      We are trying to call /api/sitecore/controller/actionname with AJAX. It's working on the CM server but not on the CD server.



      I disabled custom errors and removed HTTP error configuration in web.config, but it still redirects to the custom 404 page I've created.







      webapi






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 6 hours ago









      Dan Sinclair

      3,0312 gold badges8 silver badges30 bronze badges




      3,0312 gold badges8 silver badges30 bronze badges










      asked 9 hours ago









      Siva KumarSiva Kumar

      4563 silver badges18 bronze badges




      4563 silver badges18 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          2














          Instead of reenabling the default routes for other functionality you (probably) don't need on your CD servers, I would recommend mapping a custom route to your method and not relying on the /api/sitecore prefix.



          1. Create pipeline processor to register route



          using System.Web.Mvc;
          using System.Web.Routing;
          using Sitecore.Pipelines;

          public class RegisterWebApiRoutes
          {
          public virtual void Process(PipelineArgs args)
          {
          RouteTable.Routes.MapRoute("CustomApiRoute",
          "api/customaction",
          new { controller = "ControllerName", action = "ActionName" },
          new { httpMethod = new HttpMethodConstraint("GET") }
          );
          }
          }


          2. Create patch config to patch in your pipeline processor



          <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
          <sitecore role:require="Standalone OR ContentManagement OR ContentDelivery">
          <pipelines>
          <initialize>
          <processor type="Custom.Pipelines.Initialize.RegisterWebApiRoutes,Custom" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']"/>
          </initialize>
          </pipelines>
          </sitecore>
          </configuration>


          3. Update your code to reference this new route



          Don't forget to update your code to use the new route!






          share|improve this answer
























          • your answer is reasonable and obvious. but question is not how to implement your cusom route, question is why "/api/sitecore is not working in CD server"

            – x3mxray
            2 hours ago











          • In my opinion, both answers are missing the mark. This answer is more accurate because it offers a path forward that is more of a best practice and explained well. While @x3mxray's answer is short and answers the immediate question, it offers a hack that shouldn't actually be done. That is why I upvoted this answer.

            – Pete Navarra
            1 hour ago





















          2














          It was moved to SPEAK routes in Sitecore 9 and unavailable on CD server. You can resolve it by adding this snippet to your routing configuration (if you really need this API route - best practice is to create your own routes for your API calls):



          if (ConfigurationManager.AppSettings["role:define"] == "ContentDelivery")
          {
          RouteTable.Routes.MapRoute("Sitecore.Speak.Commands", "api/sitecore/{controller}/{action}");
          }





          share|improve this answer




























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "664"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f19716%2fapi-sitecore-is-not-working-in-cd-server%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            Instead of reenabling the default routes for other functionality you (probably) don't need on your CD servers, I would recommend mapping a custom route to your method and not relying on the /api/sitecore prefix.



            1. Create pipeline processor to register route



            using System.Web.Mvc;
            using System.Web.Routing;
            using Sitecore.Pipelines;

            public class RegisterWebApiRoutes
            {
            public virtual void Process(PipelineArgs args)
            {
            RouteTable.Routes.MapRoute("CustomApiRoute",
            "api/customaction",
            new { controller = "ControllerName", action = "ActionName" },
            new { httpMethod = new HttpMethodConstraint("GET") }
            );
            }
            }


            2. Create patch config to patch in your pipeline processor



            <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
            <sitecore role:require="Standalone OR ContentManagement OR ContentDelivery">
            <pipelines>
            <initialize>
            <processor type="Custom.Pipelines.Initialize.RegisterWebApiRoutes,Custom" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']"/>
            </initialize>
            </pipelines>
            </sitecore>
            </configuration>


            3. Update your code to reference this new route



            Don't forget to update your code to use the new route!






            share|improve this answer
























            • your answer is reasonable and obvious. but question is not how to implement your cusom route, question is why "/api/sitecore is not working in CD server"

              – x3mxray
              2 hours ago











            • In my opinion, both answers are missing the mark. This answer is more accurate because it offers a path forward that is more of a best practice and explained well. While @x3mxray's answer is short and answers the immediate question, it offers a hack that shouldn't actually be done. That is why I upvoted this answer.

              – Pete Navarra
              1 hour ago


















            2














            Instead of reenabling the default routes for other functionality you (probably) don't need on your CD servers, I would recommend mapping a custom route to your method and not relying on the /api/sitecore prefix.



            1. Create pipeline processor to register route



            using System.Web.Mvc;
            using System.Web.Routing;
            using Sitecore.Pipelines;

            public class RegisterWebApiRoutes
            {
            public virtual void Process(PipelineArgs args)
            {
            RouteTable.Routes.MapRoute("CustomApiRoute",
            "api/customaction",
            new { controller = "ControllerName", action = "ActionName" },
            new { httpMethod = new HttpMethodConstraint("GET") }
            );
            }
            }


            2. Create patch config to patch in your pipeline processor



            <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
            <sitecore role:require="Standalone OR ContentManagement OR ContentDelivery">
            <pipelines>
            <initialize>
            <processor type="Custom.Pipelines.Initialize.RegisterWebApiRoutes,Custom" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']"/>
            </initialize>
            </pipelines>
            </sitecore>
            </configuration>


            3. Update your code to reference this new route



            Don't forget to update your code to use the new route!






            share|improve this answer
























            • your answer is reasonable and obvious. but question is not how to implement your cusom route, question is why "/api/sitecore is not working in CD server"

              – x3mxray
              2 hours ago











            • In my opinion, both answers are missing the mark. This answer is more accurate because it offers a path forward that is more of a best practice and explained well. While @x3mxray's answer is short and answers the immediate question, it offers a hack that shouldn't actually be done. That is why I upvoted this answer.

              – Pete Navarra
              1 hour ago
















            2












            2








            2







            Instead of reenabling the default routes for other functionality you (probably) don't need on your CD servers, I would recommend mapping a custom route to your method and not relying on the /api/sitecore prefix.



            1. Create pipeline processor to register route



            using System.Web.Mvc;
            using System.Web.Routing;
            using Sitecore.Pipelines;

            public class RegisterWebApiRoutes
            {
            public virtual void Process(PipelineArgs args)
            {
            RouteTable.Routes.MapRoute("CustomApiRoute",
            "api/customaction",
            new { controller = "ControllerName", action = "ActionName" },
            new { httpMethod = new HttpMethodConstraint("GET") }
            );
            }
            }


            2. Create patch config to patch in your pipeline processor



            <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
            <sitecore role:require="Standalone OR ContentManagement OR ContentDelivery">
            <pipelines>
            <initialize>
            <processor type="Custom.Pipelines.Initialize.RegisterWebApiRoutes,Custom" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']"/>
            </initialize>
            </pipelines>
            </sitecore>
            </configuration>


            3. Update your code to reference this new route



            Don't forget to update your code to use the new route!






            share|improve this answer













            Instead of reenabling the default routes for other functionality you (probably) don't need on your CD servers, I would recommend mapping a custom route to your method and not relying on the /api/sitecore prefix.



            1. Create pipeline processor to register route



            using System.Web.Mvc;
            using System.Web.Routing;
            using Sitecore.Pipelines;

            public class RegisterWebApiRoutes
            {
            public virtual void Process(PipelineArgs args)
            {
            RouteTable.Routes.MapRoute("CustomApiRoute",
            "api/customaction",
            new { controller = "ControllerName", action = "ActionName" },
            new { httpMethod = new HttpMethodConstraint("GET") }
            );
            }
            }


            2. Create patch config to patch in your pipeline processor



            <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
            <sitecore role:require="Standalone OR ContentManagement OR ContentDelivery">
            <pipelines>
            <initialize>
            <processor type="Custom.Pipelines.Initialize.RegisterWebApiRoutes,Custom" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']"/>
            </initialize>
            </pipelines>
            </sitecore>
            </configuration>


            3. Update your code to reference this new route



            Don't forget to update your code to use the new route!







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 6 hours ago









            Dan SinclairDan Sinclair

            3,0312 gold badges8 silver badges30 bronze badges




            3,0312 gold badges8 silver badges30 bronze badges













            • your answer is reasonable and obvious. but question is not how to implement your cusom route, question is why "/api/sitecore is not working in CD server"

              – x3mxray
              2 hours ago











            • In my opinion, both answers are missing the mark. This answer is more accurate because it offers a path forward that is more of a best practice and explained well. While @x3mxray's answer is short and answers the immediate question, it offers a hack that shouldn't actually be done. That is why I upvoted this answer.

              – Pete Navarra
              1 hour ago





















            • your answer is reasonable and obvious. but question is not how to implement your cusom route, question is why "/api/sitecore is not working in CD server"

              – x3mxray
              2 hours ago











            • In my opinion, both answers are missing the mark. This answer is more accurate because it offers a path forward that is more of a best practice and explained well. While @x3mxray's answer is short and answers the immediate question, it offers a hack that shouldn't actually be done. That is why I upvoted this answer.

              – Pete Navarra
              1 hour ago



















            your answer is reasonable and obvious. but question is not how to implement your cusom route, question is why "/api/sitecore is not working in CD server"

            – x3mxray
            2 hours ago





            your answer is reasonable and obvious. but question is not how to implement your cusom route, question is why "/api/sitecore is not working in CD server"

            – x3mxray
            2 hours ago













            In my opinion, both answers are missing the mark. This answer is more accurate because it offers a path forward that is more of a best practice and explained well. While @x3mxray's answer is short and answers the immediate question, it offers a hack that shouldn't actually be done. That is why I upvoted this answer.

            – Pete Navarra
            1 hour ago







            In my opinion, both answers are missing the mark. This answer is more accurate because it offers a path forward that is more of a best practice and explained well. While @x3mxray's answer is short and answers the immediate question, it offers a hack that shouldn't actually be done. That is why I upvoted this answer.

            – Pete Navarra
            1 hour ago















            2














            It was moved to SPEAK routes in Sitecore 9 and unavailable on CD server. You can resolve it by adding this snippet to your routing configuration (if you really need this API route - best practice is to create your own routes for your API calls):



            if (ConfigurationManager.AppSettings["role:define"] == "ContentDelivery")
            {
            RouteTable.Routes.MapRoute("Sitecore.Speak.Commands", "api/sitecore/{controller}/{action}");
            }





            share|improve this answer






























              2














              It was moved to SPEAK routes in Sitecore 9 and unavailable on CD server. You can resolve it by adding this snippet to your routing configuration (if you really need this API route - best practice is to create your own routes for your API calls):



              if (ConfigurationManager.AppSettings["role:define"] == "ContentDelivery")
              {
              RouteTable.Routes.MapRoute("Sitecore.Speak.Commands", "api/sitecore/{controller}/{action}");
              }





              share|improve this answer




























                2












                2








                2







                It was moved to SPEAK routes in Sitecore 9 and unavailable on CD server. You can resolve it by adding this snippet to your routing configuration (if you really need this API route - best practice is to create your own routes for your API calls):



                if (ConfigurationManager.AppSettings["role:define"] == "ContentDelivery")
                {
                RouteTable.Routes.MapRoute("Sitecore.Speak.Commands", "api/sitecore/{controller}/{action}");
                }





                share|improve this answer















                It was moved to SPEAK routes in Sitecore 9 and unavailable on CD server. You can resolve it by adding this snippet to your routing configuration (if you really need this API route - best practice is to create your own routes for your API calls):



                if (ConfigurationManager.AppSettings["role:define"] == "ContentDelivery")
                {
                RouteTable.Routes.MapRoute("Sitecore.Speak.Commands", "api/sitecore/{controller}/{action}");
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 3 hours ago

























                answered 8 hours ago









                x3mxrayx3mxray

                1,0621 silver badge18 bronze badges




                1,0621 silver badge18 bronze badges






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Sitecore Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f19716%2fapi-sitecore-is-not-working-in-cd-server%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...