Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Daniel Ovaska
Sep 13, 2018
  3209
(2 votes)

Testing Episerver content delivery API

This will be my shortest blog post yet but hopefully it will save someone an hour when reading about my gotyas. 

Content delivery API is an API you will likely want to use if you need to get Episerver data for your client side application built on React, Angular, Vue or their friends. Installing it is pretty easy but it has a few quirks still. It still has a dependency on Episerver Find for instance so if you don't have that you are out of luck currently. You can follow this excellent guide here that helped me to get it up and running

https://mmols.io/getting-started-with-the-episerver-content-delivery-api/

  • Episerver needs to be at 11.4.0 or later
  • You need to use the new identity authentication (if you haven't upgraded from membership provider, now is the time!)
    It's fast but you might run into password hashing issues.
  • Remember that Episerver Find needs to be version 12.x.x or earlier.
    If you use a brand new Alloy site you can uninstall the version 13 and reinstall the latest version 12.
    A bit annoying but no biggie since it only takes 5 mins.
  • For an alloy site you also need some initialization that has already been done on the commerce quicksilver site that Matthew references in step 2. You will find some missing classes for this configuration here which took me a while.

https://github.com/episerver/Quicksilver/tree/master/Sources/EPiServer.Reference.Commerce.Site/Infrastructure/WebApi

  • I also noticed that in the official documentation they have an infrastucture zip file with the files about. 
  • When trying out the api from postman or similar, remember that the api is sensitive to language and that this is sent using a header. If you end up getting 404s then add the relevant language header (sv-SE or similar) to specify the language.
  • If you get the exception "A route named 'MS_attributerouteWebApi' is already in the route collection. Route names must be unique". It means that you are trying to register attribute routing multiple times. Remove one of the config.MapHttpAttributeRoutes() if you have multiple. The content delivery apis will try to register this too and you can shut this off by using appsettings if you already have this in your project. 
    <add key="episerver:contentdeliverysearch:maphttpattributeroutes" value="false" />​
    <add key="episerver:contentdelivery:maphttpattributeroutes" value="false" />

So far I have an alloy + angular 6 site up and running that gets all content from content delivery api where all text (and blocks) support direct on page editing. Works!

Sep 13, 2018

Comments

Please login to comment.
Latest blogs
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog