Troubleshoot errors in Content Delivery API
Describes common errors found in the Optimizely Content Delivery API.
Common errors
404 - ContentNotFound when trying to get content with Content DeliveryÂ
-
Do you enable the MultiSiteFilteringEnabled option?
If enabled, the Optimizely Content Delivery API returns only the current site's contents based on the request's context. -
Do you use the correct Accept-Language header?
Content Delivery API returns content based on the language passed in the Accept-Language header. Use the Accept-Language header to specify the locale variant of content that the client prefers (see Mozilla - MDN Web Docs for information).The problem is that some browsers, such as Chrome, automatically add their preferred language to the Accept-Language header if the user does not manually set the header value. In this case, the client should manually pass the Accept-Language header to prevent the browser from adding its header value.
Using the Content Delivery API in an AJAX application, you can specify or override the Accept-Language header value in your front-end code. See this external blog post for a code sample.
404 Http Error when sending a request to Content Delivery endpoints
- Have you registered Content Delivery API services?Â
To enable Content Delivery API endpoints, you need to call this line in yourStartup
file:
services.AddContentDeliveryApi()
404 Http Error when sending a request to token endpoints in EPiServer.OpenIDConnect
Make sure you have added the following lines at the bottom in Startup.cs
. (see Authenticate the API.
services.AddOpenIDConnect<ApplicationUser>(options => {
var application = new OpenIDConnectApplication() {
ClientId = "client",
ClientSecret = "secret"
};
options.Applications.Add(application);
});
I cannot get my images from my content
Use a property model converter (IPropertyModelConverter
), which lets you customize the output sent to the Content Delivery API. See an example in the Music Festival project. See also Serialization and How to customize data returned to clients.
Updated 7 months ago