Programmatically create a ContentFragment.

Avatar

Avatar

aliaksandr_hvoz

Avatar

aliaksandr_hvoz

aliaksandr_hvoz

04-05-2020

Hi guys.

Please advise me on this situation. I make a request to a specific server and get a JSON. After that, based on my data, I have to programmatically create a content fragment. This content fragment has a template. Maybe you have an example. 

 

Thank you very much in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Amol_Anand

Employee

Avatar

Amol_Anand

Employee

Amol_Anand
Employee

04-05-2020

There are multiple options to programmatically create Content Fragments in AEM.

 

1. You can use Assets HTTP API to create content fragments once you know what needs to go into the Fragment:

https://docs.adobe.com/content/help/en/experience-manager-65/assets/extending/assets-api-content-fra...

 

2. If you were already within AEM's context, you could also create content fragments programmatically as described in the following link: https://docs.adobe.com/content/help/en/experience-manager-65/developing/extending-aem/customizing-co...

 

Answers (3)

Answers (3)

Avatar

Avatar

sunjot16

Employee

Avatar

sunjot16

Employee

sunjot16
Employee

05-05-2020

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

840

Avatar

Arun_Patidar

MVP

Total Posts

3.0K

Likes

1.1K

Correct Reply

840
Arun_Patidar
MVP

05-05-2020

If you can use Experience Fragments instead of Content Fragment, would add lot of flexibility and easiness.
Not sure about your use case though.

 

Sample code - https://aemdeveloper.wordpress.com/2017/08/22/create-access-the-content-fragment-programmatically/

Avatar

Avatar

Veena_Vikram

MVP

Avatar

Veena_Vikram

MVP

Veena_Vikram
MVP

04-05-2020

@aliaksandr_hvoz  What exactly is your ask ? You need a sample to create CF programmatically ?