How To Enable Preview Features Using The Content Delivery API

In this tutorial, you will learn how to enable the preview API using Episerver Content Delivery API. Following good API design, the Episerver content delivery API follows API versioning. When communicating with the CSM you will need to decide which version of the API that you would like to use, like so:

http://www.website.com/api/episerver/v2.0/content/1?epieditmode=true&expand=*

As of writing v2 is the latest and greatest of the Content Delivery API. There is however a V3 already on the horizon. If you use Dotpeek to examine the

EPiServer.ContentApi.Cms
assembly within the
ContentApiController
you can see a number of s using a variety of versions. By default, the preview routes are no enabled. If you look closely you will see that the
[PreviewFeatureFilter]
is applied on all the Preview API end-points

Looking within the attribute you will notice that the

EnablePreviewFeatures
flag is used to determine if a preview API request should be fulfilled. If it is enabled the preview API is allowed. If not a forbidden error will be returned.

To enable the preview API like this:

More information about the content delivery API can be found here. Enjoy!