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 –

  1. 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.
  2. Add your controller to Routing Table by added a processor. Let’s say, my new pipeline is “RegisterWebApiRoutes”.
  3. Now add this processor before “Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc”. We can have the below config changes –
  4. Build the project and deploy the dll in your solutions.
  5. Call API “{{ServiceHostURL}}/api/event/GetEventList?startIndex=1&pageSize=100&lang=en” from Postman.