Try our conversational search powered by Generative AI!

Daniel Ovaska
Sep 13, 2018
  3204
(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
Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog

The A/A Test: What You Need to Know

Sure, we all know what an A/B test can do. But what is an A/A test? How is it different? With an A/B test, we know that we can take a webpage (our...

Lindsey Rogers | Apr 15, 2024

.Net Core Timezone ID's Windows vs Linux

Hey all, First post here and I would like to talk about Timezone ID's and How Windows and Linux systems use different IDs. We currently run a .NET...

sheider | Apr 15, 2024

What's new in Language Manager 5.3.0

In Language Manager (LM) version 5.2.0, we added an option in appsettings.json called TranslateOrCopyContentAreaChildrenBlockForTypes . It does...

Quoc Anh Nguyen | Apr 15, 2024