Sitecore Services Client ServicesApiController

With Sitecore 7.5 and now Sitecore 8, Sitecore.Services.Client (SSC) was introduced. This has given us a flexible and powerful framework for created Web API based rest services in Sitecore (See my introduction into Entity Service (part of Sitecore.Services.Client))

Entity Service is powerful, offering the repository pattern to implement functionality such as FindAll, FindByID, Create, Delete and Update for a given Entity (Model).

However, what happens if you want to create a completely bespoke Web API controller and don’t need any of the functionality from the repository of Entity Service. Up until now we have done something similar to my blog article here where we extend some Sitecore pipelines to register custom routes and abort those.


With Sitecore.Services.Client we now have another option available to us, ServicesApiController. ServicesApiController is a abstract class that sits on-top of the .NET ApiController, offering the same core functionality as the start controller. ServicesApiController sits within Sitecore.Services.Infrastructure so you need to make sure you include the DLL in your solution.

The advantage of using ServicesApiController means we get all the security benefits and filters of Sitecore.Service.Client Anders Laub has a blog post talking about this.


If we don’t want to extend the Sitecore pipelines to register routes for our custom controller, we can use another part of Sitecore.Services.Client – ServicesController. ServicesController is a attribute we can use to decorate our controllers, this then includes the controller is Sitecore.Services.Client routing.

Decorating our controllers with this attribute means we no longer need to extend any of the Sitecore pipelines to configure the routing. Our custom controller will now use the Sitecore.Services.Client style routing my default.

Eg. //HostName/sitecore/api/ssc/namespace-to-controller/{controller}/{id}/action.

Below is an example of a custom controller using ServiceApiController together with ServicesController.

Here is the output from a web request to the controller action.

JSON returned
JSON returned

6 thoughts on “Sitecore Services Client ServicesApiController

  1. Hi Mike,

    Have you ever used or know if it is possible to use the Entity Service Client to interact with xDB and Sitecore content together?

    I’m looking for the ability to export personalised content from Sitecore to a third party marketing system.


  2. Hey, working in a v8 update 3 environment.

    The ServicesApiController now seems to live in this dll – Sitecore.Services.Infrastructure.Web.Http
    The ServicesController now seems to live in this dll – Sitecore.Services.Core

    Not sure when, how and what has changed around the SSC dlls yet but this post has helped me implement a custom API, so thank you!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s