SDL Tridion Core Service content exposed via a REST web service

I’ve recently had to implement a REST web service that exposes SDL Tridion Core Service content.  I was surprised by how easy it was and thought that I’d highlight the relevant parts to encourage others to try it.

My REST web service is part of an MVC website that has it’s own collection of controllers.  So I’ve elected to put my REST controllers into a sub-folder called CMS.

MVC-controller-location

In Visual Studio a default MVC application also has an App_Start folder with a WebApiConfig.cs file inside it.

App-start-web-api-config

The Global.asax.cs file hooks it up to the Application_Start event.

Global-asax-application-start

By default this code adds a ‘Route’ of “api/{controller}/{id}”.  However I’ve modified ours to be “CMS” instead of “api”.

Web-api-config-register

That’s all the infrastructure in place, now we just need to populate the controller (added in screen shot #1 above).

Take a deep breath and prepare yourself folks, it’s about to get super complex……

rest-controller

So I’ve only hooked up lines 13 and 19 for now.  But what that code means is we can do this:

rest-response-publication-list

And this:

rest-response-publication-item

A REST web service exposing Tridion content via Core Service.  Don’t forget to secure the thing!

2 thoughts on “SDL Tridion Core Service content exposed via a REST web service

  1. Nice, Mark and thanks for sharing. This makes a whole lot of CM-side reporting, analysis, and generated documentation ideas that much easier to implement.

    Oh and a gentle reminder for our dear readers–do “try this at home,” just not in delivery. :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>