InvalidTemplateException while creating content fragment - ContentFragmentManager API

rajasekharb

19-02-2019

Hi,

I am trying to create a content fragment using com.adobe.cq.dam.cfm.ContentFragmentManager create method. I tried giving different content fragment model resources at create(Resource parent, Resource template, String name, String title). It always giving com.adobe.cq.dam.cfm.impl.InvalidTemplateException: Invalid template format; missing 'version' attribute.

Am I missing anything here?

@Reference

ContentFragmentManager cfm;

--

Resource parent = resourceResolver().getResource("/content/dam/fragments");

Resource template = resourceResolver().getResource("/conf/global/settings/dam/cfm/models/custommodel");// content fragment model in my local

ContentFragment contentFragment = cfm.create(parent, template, "samplefragmentname", "sample fragment title");

resourceResolver().commit();

Thanks,

Raja

Accepted Solutions (1)

Accepted Solutions (1)

Gaurav-Behl

MVP

20-02-2019

CF Model is not same as CF Template. That's the issue in this case. Either you create a CF template or use an existing editable template for the same. Create a CF manually and you'd get to know more about it.

Resource template = resourceResolver().getResource("/conf/global/settings/dam/cfm/models/custommodel");  // provide template path rather than CF model path

Refer - Content Fragment Templates