November Happy Hour will be moved to Thursday December 5th.

Connecting epiServer forms in ContentDeliveryApi MusicFestival project

Vote:
 

Hi,

I am working on connecting via the documentation the Optimizely Forms package for Content Delivery API on the vue template project MusicFestival (which has packages EpiServer.ContentDeliveryApi.Cms 2.17.0 and EpiServer.Forms 4.27)
As I try to install the compatible version of the package EPiServer.ContentDeliveryApi.Forms 2.17.0 (optimizely.com) for this project and build the project after successful installation I get a 500 error with the information:

code: "InternalServerError"
details: []
message: "The server encountered an internal error or misconfiguration"
target: null

I also tried to register CD.form in the SiteInitialization.cs file in ConfigureContainer method (in this version we do not have IServiceCollection but ServiceConfigurationContext and I see that in EPiServer.ContentApi.Forms.ContentApiFormInitialization.ConfigureContainer the code is similar):


            EPiServer.ContentApi.Forms.ContentApiFormInitialization service = new EPiServer.ContentApi.Forms.ContentApiFormInitialization();
            service.ConfigureContainer(context);

 
But it still doesn't change a thing as I am still getting 500 error. What can be the case for this issue?

#298179
Mar 13, 2023 13:09
Vote:
 

HI,

I guess, I encoutered similer error earlier, I think solution was, Uninstall the CD package and install the 2.21.1v package.

In general 2.21.1 version looks working without any issues.

Also I hope you have tried executing Update-EPiDatabase command, If not please try it out.

#298304
Mar 14, 2023 16:14
jedreqq - Mar 17, 2023 7:45
Hi Harinarayanan. I tried Update-EPiDatabase command and also I listened to your advice for upgrading the CD to 2.21.1 version (Cms, Core, Forms). Unfortunately the problem still occurs. Is there something I could be missing, or do you remember some other things you needed to change to get it done?
Vote:
 

Hi Jedreqq,

Hope you have looked into the documentation from optimizely,

https://docs.developers.optimizely.com/content-cloud/v1.5.0-content-delivery-api/docs/content-delivery-api-and-optimizely-forms .

In the above documentation the Optimizely says that, we have to register the CD.Form services by calling AddFormsApi(): and  register CD.Forms services in your IoC container. But I have not done any of those, still I'm abe to access the forms through API. This just for your information. may be an workaround. 

One more Note: I guess you must have two config in AppSettings of web.config, I not please add it.

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

#298483
Mar 17, 2023 9:31
Vote:
 

Hi Harinarayanan,
I tried to call the addFormsApi method, also worked on the AppSettings of web.config with your suggestions and I got the 404 error with the implemented in, but it feels like the configuration has something to do with the contentdeliveryapi.search, not the forms package itself. Also I tried with the 

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

setting but nothing changes at all. Also, when I looked into the episerver error log I found this information:

2023-03-24 10:27:48,803 [143] ERROR EPiServer.ContentApi.Cms.Controllers.ContentApiController: Error occurred during Content Api Request
System.NullReferenceException: Object reference not set to an instance of an object.
   at EPiServer.Forms.Controllers.FormContainerBlockController.Index(FormContainerBlock currentBlock)
   at EPiServer.ContentApi.Forms.FormRenderingService.BuildFormTemplate(IFormContainerBlock formContainerBlock)
   at EPiServer.ContentApi.Forms.FormContentModelMapper.Convert(IContent content, ConverterContext converterContext)
   at MusicFestival.Template.Models.ExtendedContentModelMapper.TransformContent(IContent content, Boolean excludePersonalizedContent, String expand) in C:\mfvue\musicfestival-vue-template\src\MusicFestival.Vue.Template\Models\ExtendedContentModelMapper.cs:line 44
   at EPiServer.ContentApi.Core.Serialization.ContentConvertingService.ConvertToContentApiModel(IContent content, ConverterContext converterContext)
   at EPiServer.ContentApi.Core.Serialization.ContentConvertingService.Convert(IContent content, ConverterContext converterContext)
   at EPiServer.ContentApi.Cms.Controllers.ContentApiController.ResultFromContent(IContent content, String expand, String select, Boolean addMetadataHeaders, ContextMode contextMode, SiteDefinition site, String remainingRoute, String language)
   at EPiServer.ContentApi.Cms.Controllers.ContentApiController.Get(String contentReference, List`1 languages, String expand, String select)
System.NullReferenceException: Object reference not set to an instance of an object.
   at EPiServer.Forms.Controllers.FormContainerBlockController.Index(FormContainerBlock currentBlock)
   at EPiServer.ContentApi.Forms.FormRenderingService.BuildFormTemplate(IFormContainerBlock formContainerBlock)
   at EPiServer.ContentApi.Forms.FormContentModelMapper.Convert(IContent content, ConverterContext converterContext)
   at MusicFestival.Template.Models.ExtendedContentModelMapper.TransformContent(IContent content, Boolean excludePersonalizedContent, String expand) in C:\mfvue\musicfestival-vue-template\src\MusicFestival.Vue.Template\Models\ExtendedContentModelMapper.cs:line 44
   at EPiServer.ContentApi.Core.Serialization.ContentConvertingService.ConvertToContentApiModel(IContent content, ConverterContext converterContext)
   at EPiServer.ContentApi.Core.Serialization.ContentConvertingService.Convert(IContent content, ConverterContext converterContext)
   at EPiServer.ContentApi.Cms.Controllers.ContentApiController.ResultFromContent(IContent content, String expand, String select, Boolean addMetadataHeaders, ContextMode contextMode, SiteDefinition site, String remainingRoute, String language)
   at EPiServer.ContentApi.Cms.Controllers.ContentApiController.Get(String contentReference, List`1 languages, String expand, String select)


I tried to debug the 44 line in ExtendedContentModelMapper but I cannot detect what is exactly missing in this line:

var contentModel = _defaultContentModelMapper.TransformContent(content, excludePersonalizedContent, expand);

Did you come across this one?

#298909
Mar 24, 2023 9:38
* 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.