HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In

Troubleshooting errors in Content Delivery API

This topic describes common errors found in the Content Delivery API.

Common errors

404 - ContentNotFound when trying to get content with Content Delivery 

  • Do you enable MultiSiteFilteringEnabled option?
    If enabled, Content Delivery API returns only the contents of the current site based on the request 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 more information).

    The problem is some browsers, such as Chrome, automatically add its preferred language to the Accept-Language header, if the header value is not manually set by the user. In this case, the client should manually pass the Accept-Language header to prevent the browser from adding its own header value.

    If you are using the Content Delivery API in an AJAX application, you can specify/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 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 your Startup 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 file (see API authentication.

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.