November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
I had the same issue, adding the key mentioned in Quan's Accepted Answer helped.
https://world.episerver.com/forum/developer-forum/Developer-to-developer/Thread-Container/2018/11/content-delivery-api---404-error/
This was the overall setup guide I found most helpful
https://world.episerver.com/blogs/david-buo/dates/2018/11/get-started-with-content-delivery-api-2-2-0/
Also, don't forget:
Thanks Darren, but unfortunately I already had the following keys in my Web.config, combined with my own call to configuration.MapHttpAttributeRoutes():
<configuration>
<appSettings>
<add key="episerver:contentdelivery:maphttpattributeroutes" value="false" />
<add key="episerver:contentdeliverysearch:maphttpattributeroutes" value="false" />
</appSettings>
<!-- ... -->
</configuration>
I have tried every combination of these settings and commented my own call to MapHttpAttributeRoutes when one of these settings was true.
I also use an initialization module:
[ModuleDependency(typeof(ContentApiCmsInitialization))]
public class ContentDeliveryApiInitialization : IConfigurableModule
{
public void Initialize(InitializationEngine context)
{
//Add initialization logic, this method is called once after CMS has been initialized
}
public void Uninitialize(InitializationEngine context)
{
//Add uninitialization logic
}
public void ConfigureContainer(ServiceConfigurationContext context)
{
// set minimumRoles to empty to allow anonymous calls (for visitors to view site in view mode)
context.Services.Configure<ContentApiConfiguration>(config =>
{
config.Default().SetMinimumRoles(string.Empty);
});
}
}
But I do think this has mainly to do with some problem with the routing.
Hi,
404 error could be caused by many reasons. please check your handlers in webconfig
Hi Twan,
Try commenting out the first key in Web.config
I found when I have both keys Web.config I get the 404 error requesting any of the /content URLs
See below my request in Postman that returns 404.
But after I comment out the first key in Web.config.
<!--<add key="episerver:contentdelivery:maphttpattributeroutes" value="false" />-->
<add key="episerver:contentdeliverysearch:maphttpattributeroutes" value="false" />
Postman returns the JSON result expected.
Hope this helps, my local is a clean install of Alloy + Episerver Content Delivery API.
But as Quan said, there are could be other things going on in your particular setup.
Hello,
I'm trying to enable the Content Delivery Api in my application, but it seems I have a problem with routing. I simply added the NuGet packages "EPiServer.ContentDeliveryApi.Cms" and "EPiServer.ContentDeliveryApi.Core" to my project. I then tested this configuration by making a call from a browser (authenticated) from JavaScript. The call looks like follows:
A call to "/api/episerver/v2.0/site" does work:
I know that the content delivery api also generated 404 responses if the content is not found or maybe in some other cases, but I don't think this is the case. I added the following to make sure the request was handled by a route:
When inspecting routeData after a JavaScript call to "/api/episerver/v2.0/content" routeData is null. When I explicitly add a route for this URL the routeData is not null:
When I make an override controller in my own code where I just call the base everywhere and set the same attributes when everything works fine.
To me it seems that the Route attributes in the ContentApiController class in the EPiServer.ContentDeliveryApi.CMS assembly are not found, but the strange thing is dat the sibling controller (SiteDefinitionApiController) is.
Anyone any ideas on how to get the routes for the content delivery api to work?
Thanks!