Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Programmatically create a ContentFragment.

aliaksandr_hvoz
Level 2
Level 2

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.

1 Accepted Solution
Amol_Anand
Correct answer by
Employee
Employee

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...

 

View solution in original post

4 Replies
Veena_Vikram
Community Advisor
Community Advisor

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

Amol_Anand
Correct answer by
Employee
Employee

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...

 

View solution in original post

Arun_Patidar
Community Advisor
Community Advisor

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/