I 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 its 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!
This article was originally published by Mark Sizer at: http://www.tridiondeveloper.com/sdl-tridion-core-service-content-exposed-via-a-rest-web-service