The Optimizely Content Delivery API adds headless capabilities to your traditional Optimizely Content Cloud CMS, making it a hybrid CMS. The best of both worlds, you might say.
The documentation is quite good, so I just want to mention the problems I had installing the Content Delivery API for the first time. And then, of course, how to solve those problems. If I had actually read the entire documentation, I would have found the solution to at least one of my problems... 😄
A route named 'MS_attributerouteWebApi' is already in the route collection
The first problem I faced after installing the Content Delivery API, was this message.
After some investigation, I think the problem is multiple calls to
MapHttpAttributeRoutes() and adding the following appsettings seems to fix the problem.
<add key="episerver:contentdeliverysearch:maphttpattributeroutes" value="false"/>
<add key="episerver:contentdelivery:maphttpattributeroutes" value="false"/>
404 Content was not found from the API
The first thing I did after installing the Content Delivery API, and getting rid of the error message above, was try to test the API in my browser of choice, with the following result. I knew the content with id 8 existed, so I did not understand this response from the API.
I made all kinds of changes to the configuration and even reached out to Optimizely support. I gave support access to my test site, and the answer I got was
It works on my machine!
Finally, a colleague of mine listened to my problems, did a quick Google search, and told me the solution within a minute! Thanks, Henning!
The problem was that the
Accept-Language header must match the content you are querying for. The support guy obviously had different preferred language settings in his browser, so that's why it worked on his machine.
The easiest way of checking your browser settings is using a service like this. This is what my browser «accepts».
The easiest way to test the Content Delivery API is to use Postman, or a similar tool, where you have full control over the
After running some tests, my conclusion is that if presented with a list of languages (like from my browser) the Content Delivery API will only look at the first language and ignore the rest. Which, by the way, makes total sense!
Content Search API
While the documentation tells you how to use the Search API, I was unable to find the actual base URL! So, here it is:
For details on how to use the API, refer to the documentation linked above.
Except for those three minor problems, getting started with the Content Delivery API was a piece of cake! 🍰