How to Implement a backend API or service to fetch content fragments from the CMS
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @ssin93 ,
There are two ways through which you can achieve this:
1. Use AEM’s GraphQL APIs for Content Fragments which supports headless CMS scenarios wherein external client applications render experiences using content managed in AEM.
Checkout this article for more details on it:
https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/g...
2. Write your custom servlet which will invoke a service class that in turn will return the JSON data from Content fragment.
3. Make your content fragment adaptable through sling model and use exporter in it.
I'd recommend you to go for the first AEM Graph QL.
Thanks
Tarun
Hi @ssin93 ,
There are two ways through which you can achieve this:
1. Use AEM’s GraphQL APIs for Content Fragments which supports headless CMS scenarios wherein external client applications render experiences using content managed in AEM.
Checkout this article for more details on it:
https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/g...
2. Write your custom servlet which will invoke a service class that in turn will return the JSON data from Content fragment.
3. Make your content fragment adaptable through sling model and use exporter in it.
I'd recommend you to go for the first AEM Graph QL.
Thanks
Tarun
@ssin93 Below is a design suggestion on implementing the API to read content fragment
API Endpoint Design:
Create Backend Routes:
CMS Integration:
Data Mapping:
Hi @ssin93
What is your use case here?Like where you need this CF data as in a Component using Sling Model or at some other place?
We have implemented a similar service where we pass CF path and it will retrive all the Content in JSON format and can be used anywhere.
Let me know if I I can help further on this.
@ssin93 ,
There are multiple ways to retrieve content fragments data based on the use case. Please see below the OOTB approaches to retrieve the CF data and export as JSON.
1) AEM GraphQL API: https://experienceleague.adobe.com/docs/experience-manager-65/assets/content-fragments/content-fragm...
2) Content Fragments using Assets HTTP API: https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/assets/admin/assets...
Views
Likes
Replies
Views
Likes
Replies