Content Delivery API - 404 error

Vote:
 

I wanted to play around with content API unfortunatelly I stucked with a bit weird issue. I'm getting 404 error on search api (/api/episerver/v2.0/search/content) or cms api (ie. /api/episerver/v2.0/site) depending on which dependency was installed first. So if I install cms api as the first one, I'm getting 404 on search API and in the opposite. It seems like the second one is not registerd. Do you have any idea why it might be like this? Is it possible that it really depeneds on installation order?

Regards,

Maciek

#199187
Nov 19, 2018 17:11
Vote:
 

Hi Maciej,

Sorry for my late response.

1. If the site installs both cms and search packages, and does not use any kind of service API, one of two lines below should be added to appSettings. This prevents (HttpConfiguration)config.MapHttpAttributeRoutes() from being called twice, which otherwise causes an exception (404).

Disable settings from ContentDeliverApi.Cms:

<add key="episerver:contentdelivery:maphttpattributeroutes" value="false" />

Disable settings from ContentDeliverApi.Search:

<add key="episerver:contentdeliverysearch:maphttpattributeroutes" value="false" />

2. In order to enable SiteDefinition API, you should override the default configuration

[ModuleDependency(typeof(ContentApiCmsInitialization))] public class ExtendedContentApiCmsInitialization : IConfigurableModule { public void Initialize(InitializationEngine context) { } public void Uninitialize(InitializationEngine context) { } public void ConfigureContainer(ServiceConfigurationContext context) { context.Services.Configure<ContentApiConfiguration>(config => { config.Default() .SetSiteDefinitionApiEnabled(true); }); } }

For more information about how to configure content delivery api, go Content Delivery Configuration

Hop this help.

#199266
Edited, Nov 22, 2018 10:30
Vote:
 

Questions or discusstions related to ContentDeliveryApi or addons, you can post it here https://world.episerver.com/forum/developer-forum/Addons/  so that we can quickly reply.

#199267
Edited, Nov 22, 2018 10:33
Vote:
 

Thx for the response. Unfortunately I already have an appSetting key and I also have an initialization class that you have mentioned but I still get 404 for search or cms api.

I should mentioned about it in my question.

Regards,

Maciek 

#199268
Edited, Nov 22, 2018 10:49
Vote:
 

Thx for the response. Unfortunately I already have an appSetting key and I also have an initialization class that you have mentioned but I still get 404 for search or cms api.

I should mentioned about it in my question.

Best,

Maciek 

#199269
Nov 22, 2018 10:49
Vote:
 

Have you had such a think like <episerver.find serviceUrl="https://...." defaultIndex="index name" />. To be able to run EPiServer.Find, you need it.
 

#199270
Nov 22, 2018 10:52
Vote:
 

Yes it's there.

As I mentioned it's working just for one API (search or cms api) depending which was installed as a first via nuget manager, what is super odd.

#199271
Nov 22, 2018 10:55
Vote:
 

Do you have any other kind of webapi services ?

Try disabling settings from ContentDeliverApi.Cms and ContentDeliverApi.Search:

<add key="episerver:contentdelivery:maphttpattributeroutes" value="false" />
<add key="episerver:contentdeliverysearch:maphttpattributeroutes" value="false" />

Also under <system.web> set optimizeCompilations to false to prevent site/IIS from caching.

<compilation debug="true" targetFramework="4.6.1" optimizeCompilations="false" />

After that you can revert optimizeCompilations settings (set it to true as default)

#199272
Edited, Nov 22, 2018 10:58
Vote:
 

Ahhh!

<compilationdebug="true"targetFramework="4.6.1"optimizeCompilations="false">

Solved the problem!

Thx Quan! :)

Regards,

Maciek

#199273
Edited, Nov 22, 2018 11:03
Vote:
 

Nice :)

#199274
Nov 22, 2018 11:05
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.