Abstract
In most cases, we need to share the CMS content with external systems to support the Omni channel's headless experiences or other use cases to support content sharing.
In this post, let us see the options available to share the AEM content with external systems.
GRAPH QL:
The graph QL API shares the content fragments to enable the headless content experience with the external system. The structured data can be managed through Content Fragments in AEM and shared through Graph QL API to support the omnichannel experiences. The latest AEM 6.5 and AEM as a Clod Services versions support Graph QL API; the Graph QL API currently supports only exposing content fragments externally, not for the regular page content.
Refer to the following URL for more details on using Graph QL to API to share content fragments with external systems — https://medium.com/tech-learnings/how-to-deliver-headless-content-through-graphql-api-and-content-fragments-da2b2d22df06
CONTENT AS A SERVICE/SLING MODEL EXPORTER:
Sling Model Exporter allows annotations — @Exporter(name = "jackson", extensions = "json") to be added to Sling Models that define how the Model can be exported as JSON. The page JSON data can be accessed by adding a model selector — this prints all the data exposed through different sling models.
http://localhost:4502/content/wknd/us/en.model.tidy.json (tidy selector formats the JSON response)
The sling exporter exposes all the components model data enabled on this page as a JSON response. The JSON response can render the page in an external channel to enable the headless experience.
The content as a service supports authoring of the Content fragments into a page and exposes the content through JSON exporter(by adding .model selector as discussed above)
Refer to https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/understand-sling-model-exporter.html?lang=en for more details on Sling Model Exporter.
QUERY BUILDER JSON API:
The Query Builder offers an easy way of querying the content repository of AEM. The REST API provides the functionality to execute JCR queries through HTTP requests and respond with JSON.
The JSON REST API can share the data to an external system, mainly the metadata about pages and assets, e.g., useful when the onsite search platform requires additional metadata for indexing Assets.
http://localhost:4502/bin/querybuilder.json?p.hits=selective&p.limit=-1&p.properties=jcr%3apath%20jcr%3acontent%2fmetadata%2fdc%3atitle%20jcr%3acontent%2fmetadata%2fdc%3adescription&path=%2fcontent%2fdam&type=dam%3aAsset
Change the query to fetch the required content properties on the JSON response.
{
"success": true,
"results": 5,
"total": 5,
"more": false,
"offset": 0,
"hits": [
{
"jcr:path": "/content/dam/sampledata",
"jcr:content": {
"metadata": {}
}
},
{
"jcr:path": "/content/dam/spaeditableareas/asset.jpg",
"jcr:content": {
"metadata": {}
}
},
{
"jcr:path": "/content/dam/spassr/asset.jpg",
"jcr:content": {
"metadata": {}
}
},
{
"jcr:path": "/content/dam/wknd/test.csv",
"jcr:content": {
"metadata": {}
}
},
{
"jcr:path": "/content/dam/wknd/asset.jpg",
"jcr:content": {
"metadata": {
"dc:description": "test description",
"dc:title": "test title"
}
}
}
]
}
Read Full Blog
Q&A
Please use this thread to ask the related questions.
Kautuk Sahni