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.
In Visual Studio a default MVC application also has an App_Start folder with a WebApiConfig.cs file inside it.
The Global.asax.cs file hooks it up to the Application_Start event.
By default this code adds a ‘Route’ of “api/{controller}/{id}”. Â However I’ve modified ours to be “CMS” instead of “api”.
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……
So I’ve only hooked up lines 13 and 19 for now. Â But what that code means is we can do this:
And this:
A REST web service exposing Tridion content via Core Service. Â Don’t forget to secure the thing!
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.![:-)](http://www.tridiondeveloper.com/wp-includes/images/smilies/simple-smile.png)
Perfect ! Thanks for sharing![:)](http://www.tridiondeveloper.com/wp-includes/images/smilies/simple-smile.png)