In this tutorial, you will learn how to enable the Episerver content delivery API to return preview data. Following good API design, the Episerver content delivery API follows API versioning. When communicating with the CMS you will need to decide which version of the API that you would like to use, like so:
As of writing, v2 is the latest and greatest version 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 rules. By default, the preview routes are not 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 requests are allowed. If not, preview requests will be treated as forbidden and an error will be returned. This means that to enable the preview API can be done by enableding EnablePreviewFeatures
like this:
More information about the content delivery API can be found here. Enjoy!