Setting up a DD4T REST service

With the release of DD4T 2.0 at Tridion Development Summit in Amsterdam in September, an additional way to consume content from Tridion (or SDL Web) was introduced: using a REST Service. In this article you will find a step by step tutorial how to setup this service.

  1. Start Microsoft Visual Studio and create a new project: “ASP.NET Web Application”RestService-1
  2. In the next screen, select the “Empty” templateRestService-2
  3. Install NuGet package “DD4T.RestService.WebApi”
  4. Depending on your Tridion version install the correct nuget package DD4T.Providers.SDLTridionXXX.  DD4T 2.0 supports Tridion 2011 SP1 version and above. for Tridion2013Sp1 install package
  5. Change the Log location on disk in your updated Web.config.
  6. Add the Tridion configuration files and lib directory to the bin folder of the project.
    • \Config folder
    • \Lib folder
    • netrtsn.dll
    • Tridion.ContentDelivery.AmbientData.dll
    • Tridion.ContentDelivery.Configuration.dll
    • Tridion.ContentDelivery.dll
    • Tridion.ContentDelivery.Interop.dll
    • xmogrt.dll
  7. Add references to the Tridion DLL files to the project
    • Tridion.ContentDelivery.AmbientData.dll
    • Tridion.ContentDelivery.Configuration.dll
    • Tridion.ContentDelivery.dll
    • Tridion.ContentDelivery.Interop.dll

DD4T.RestService.WebApi implements controller for the default DD4T Providers, so the service is now ready for use!

The following Controllers are implemented:

  • Page
  • ComponentPresentation
  • Link
  • Binary

Routes to PageController:

http://myurl/Page/GetContentByUrl/{publicationId:int}/{extension}/{*url}
Example: http://myurl/Page/GetContentByUrl/5/html/index

http://myurl/Page/GetContentByUri/{publicationId:int}/{id:int}
Example: http://myurl/Page/GetContentByUri/5/123

http://myurl/Page/GetLastPublishedDateByUrl/{publicationId:int}/{extension}/{*url}
Example: http://myurl/Page/GetLastPublishedDateByUrl/5/html/index

http://myurl/Page/GetLastPublishedDateByUri/{publicationId:int}/{id:int}
Example: http://myurl/Page/GetLastPublishedDateByUri/5/123

Routes to ComponentPresentationController

http://myurl/componentpresentation/GetContent/{publicationId:int}/{id:int}
Example: http://myurl/componentpresentation/GetContent/5/123

http://myurl/componentpresentation/GetContent/{publicationId:int}/{id:int}/{templateId?}
Example: http://myurl/componentpresentation/GetContent/5/123/678

http://myurl/componentpresentation/GetLastPublishedDate/{publicationId:int}/{id:int}
Example: http://myurl/componentpresentation/GetContent/5/123

http://myurl/componentpresentation/GetContentMultiple/{publicationId:int}/{ids}
Example: http://myurl/componentpresentation/GetContent/5/123,345,88,765

Routes to LinkController

http://myurl/link/ResolveLink/{publicationId:int}/{componentUri:int}
Example: http://myurl/link/ResolveLink/5/123

http://myurl/link/ResolveLink/{publicationId:int}/{componentUri:int}/{sourcePageUri:int}/{excludeComponentTemplateUri:int}
Example: http://myurl/link/ResolveLink/5/234/1234

Routes to BinaryController

http://myurl/binary/GetBinaryByUri/{publicationId:int}/{id:int}
Example: http://myurl/binary/GetBinaryByUri/5/445

http://myurl/binary/GetBinaryByUrl/{publicationId:int}/{extension}/{*url}
Example: http://myurl/binary/GetBinaryByUrl/5/jpg/images/myImage

http://myurl/binary/GetBinaryStreamByUri/{publicationId:int}/{id:int}
Example: http://myurl/binary/GetBinaryStreamByUri/5/445

http://myurl/binary/GetBinaryStreamByUrl/{publicationId:int}/{extension}/{*url}
Example: http://myurl/binary/GetBinaryStreamByUrl/5/jpg/images/myImage

http://myurl/binary/GetLastPublishedDateByUri/{publicationId:int}/{id:int}
Example: http://myurl/binary/GetLastPublishedDateByUri/5/445

http://myurl/binary/GetLastPublishedDateByUrl/{publicationId:int}/{extension}/{*url}
Example: http://myurl/binary/GetLastPublishedDateByUrl/5/jpg/images/myImage

http://myurl/binary/GetUrlForUri/{publicationId:int}/{id:int}
Example: http://myurl/binary/GetUrlForUri/5/445

Accelerate Tridion development and become an expert in DD4T with Trivident’s 2-day in-depth training course.