Programmatically create a ContentFragment. | Community
Skip to main content
aliaksandr_hvoz
Level 2
May 4, 2020
Solved

Programmatically create a ContentFragment.

  • May 4, 2020
  • 4 replies
  • 15492 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by amolanand

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-fragments.html#create

 

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-content-fragments.html#example-creating-a-new-content-fragment

 

4 replies

VeenaVikraman
Community Advisor
Community Advisor
May 4, 2020

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

amolanandAdobe EmployeeAccepted solution
Adobe Employee
May 4, 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-fragments.html#create

 

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-content-fragments.html#example-creating-a-new-content-fragment

 

arunpatidar
Community Advisor
Community Advisor
May 5, 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/

Arun Patidar
sunjot16
Adobe Employee
Adobe Employee
May 5, 2020