How to expose Sitecore API for the outside world
There is very simple way to expose the Sitecore controller to the outside world.
Let’s do it –
- Write a Controller like EventController and add a method called GetEventList. Very simple Get method with some Pagesize and Language. You can make all the parameters optional.
- Add your controller to Routing Table by added a processor. Let’s say, my new pipeline is “RegisterWebApiRoutes”.
- Now add this processor before “Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc”. We can have the below config changes –
- Build the project and deploy the dll in your solutions.
- Call API “{{ServiceHostURL}}/api/event/GetEventList?startIndex=1&pageSize=100&lang=en” from Postman.