Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Programmatically create a ContentFragment.

Avatar

Level 3

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

Avatar

Correct answer by
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

Avatar

Community Advisor

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

Avatar

Correct answer by
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...

 

Avatar

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/



Arun Patidar