Sunday, 6 August 2023

AEM Content Fragments using Assets HTTP API - Postman Collection

Adobe Experience Manager (AEM) is a powerful content management system that empowers marketers and content creators to manage digital assets efficiently. One of the key features in AEM is Content Fragments, which allows users to create and manage reusable content elements across different channels. In this blog post, we will explore AEM Content Fragments and how to interact with them using the Assets HTTP API.

What are Content Fragments?

Content Fragments in AEM are content elements that represent modular, structured pieces of content. They are designed to be used across multiple pages, channels, and websites, ensuring consistent messaging and branding. Unlike regular assets, Content Fragments are intended for reuse and are not meant to be published as standalone pages.

Advantages of Content Fragments:

  1. Reusability: Create once, use anywhere – Content Fragments can be used across multiple pages, campaigns, or even different AEM instances.
  2. Centralized Management: AEM provides a central location for managing Content Fragments, allowing for easy updates and versioning.
  3. Structured Content: Content Fragments are based on predefined models, enforcing consistency in the content structure.
  4. Multilingual Support: Easily manage multilingual content using different variations within a single Content Fragment.

Interacting with AEM Content Fragments using Assets HTTP API

AEM provides an HTTP API, specifically the Assets HTTP API, to interact with various asset types, including Content Fragments. Below are some common operations using the Assets HTTP API to manage Content Fragments programmatically.

  1. Create a Content Fragment: To create a new Content Fragment, make a POST request to the appropriate endpoint, providing the required metadata and elements in the request body. The Content Fragment will be stored as a JSON structure.
POST /api/assets/myfolder/myfragment
Authorization: Bearer {{your_access_token}}
Content-Type: application/json

{
  "jcr:primaryType": "dam:Asset",
  "jcr:content": {
    "jcr:primaryType": "dam:AssetContent",
    "jcr:mimeType": "application/vnd.adobe.fragment+json",
    "data": {
      "elements": {
        "title": "My Content Fragment",
        "description": "This is a sample content fragment.",
        "myCustomField": "Custom value"
      }
    }
  }
}

  1. Retrieve Content Fragment Metadata: To fetch the metadata of a specific Content Fragment, make a GET request to the corresponding endpoint.
GET /api/assets/myfolder/myfragment Authorization: Bearer {{your_access_token}}

  1. Update Content Fragment Metadata: To update the metadata of an existing Content Fragment, make a PUT request with the updated metadata in the request body.

PUT /api/assets/myfolder/myfragment
Authorization: Bearer {{your_access_token}}
Content-Type: application/json

{
  "jcr:primaryType": "dam:Asset",
  "jcr:content": {
    "jcr:primaryType": "dam:AssetContent",
    "jcr:mimeType": "application/vnd.adobe.fragment+json",
    "data": {
      "elements": {
        "title": "Updated Title",
        "description": "This is an updated content fragment.",
        "myCustomField": "New value"
      }
    }
  }
}

  1. Delete Content Fragment: To remove a Content Fragment, make a DELETE request to the corresponding endpoint.
DELETE /api/assets/myfolder/myfragment Authorization: Bearer {{your_access_token}}

Conclusion

AEM Content Fragments are a powerful feature that streamlines content management and promotes content reuse across various channels and campaigns. Leveraging the Assets HTTP API, developers can efficiently interact with Content Fragments programmatically, enabling seamless integration with external systems and applications.

By understanding the basics of Content Fragments and mastering the Assets HTTP API, organizations can create a more agile and scalable content management process, ensuring consistent and engaging digital experiences for their audiences.

Postman collection For AEM Content Fragments is published here.

Saturday, 5 August 2023

AEM Assets HTTP API Postman collection

Introduction

Adobe Experience Manager (AEM) is a leading content management system that empowers enterprises to efficiently manage their digital assets. Whether it's images, videos, documents, or other media files, AEM provides a robust and scalable platform for organizing and delivering assets across various channels. In this blog post, we'll explore the AEM Asset HTTP API, a powerful tool that enables seamless integration with AEM's asset management capabilities.

What is the AEM Asset HTTP API?

The AEM Asset HTTP API is a RESTful API that allows developers to interact with AEM's Digital Asset Management (DAM) system programmatically. It provides a set of HTTP endpoints to create, retrieve, update, and delete digital assets, folders, and collections within the AEM DAM.

Key Benefits of Using the AEM Asset HTTP API:

  1. Automation and Integration: The API facilitates integration with third-party applications, marketing automation platforms, and other systems, streamlining asset management workflows.

  2. Customization: Developers can build custom asset management solutions tailored to specific business needs using the API.

  3. Batch Operations: The API supports batch operations, allowing multiple asset operations to be performed in a single request, optimizing performance.

  4. Enhanced Performance: By utilizing the API, asset operations can be executed remotely, reducing the load on the AEM server.

Getting Started with the AEM Asset HTTP API:

Before diving into the API, you need to ensure you have the necessary access and authentication to interact with AEM programmatically. AEM provides various authentication mechanisms, including OAuth2 and basic authentication. Once authenticated, you'll receive an access token that needs to be included in your API requests as the "Authorization" header.

To access the API:

  1. Open the API service document at https://[hostname]:[port]/api.json.
  2. Follow the Assets service link leading to https://[hostname]:[server]/api/assets.json.
I have created a postman collection for most of the operations on the assets, folders and renditions.


I have published the postman collection here.




Friday, 14 July 2023

AEM WCM Component Core bundle is not active

I am trying to run WKND site on AEM 6.5.12. Created AEM Project using below archetype command.

mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate \
 -D archetypeGroupId=com.adobe.aem \
 -D archetypeArtifactId=aem-project-archetype \
 -D archetypeVersion=41\
 -D aemVersion=6.5.12 \
 -D appTitle="WKND App" \
 -D appId="wknd-app" \
 -D groupId="com.adobe.aem.guides.wkndapp" -D frontendModule="decoupled"

I am getting below error when loading the WKND home page properties.


Compilation errors in org/apache/sling/scripting/sightly/apps/core/wcm/components/commons/editor/dialog/inherited/v1/inherited/render_html.java: Line 39, column 2543 : com.adobe.cq.wcm.core.components.commons.editor.dialog.inherited.InheritedField cannot be resolved to a type.

To fix this error, check the core component bundle status.



 If bundle is not active then check the AEM version and Core component compatibility at here


After installing 2.19.2 version for AEM 6.5.12 then bundle status is changed to active.



Thursday, 13 July 2023

HTTP ERROR 503 AuthenticationSupport service missing. Cannot authenticate request.

 I was not able to login to local AEM instance and figured out instance is working after removing the repoint folder under path "crx-quickstart/launchpad/config/org/apache/sling/jcr/repoinit".



Friday, 7 July 2023

java.nio.file.FileSystemException: dispatcher\src\conf.d\enabled_vhosts\aem_author.vhost: A required privilege is not held by the client.

When creating new AEM Project using maven archetype version 41, I was getting below error.

"[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate (default-cli) on project standalone-pom:  java.nio.file.FileSystemException: C:\Kishore\aem-nextjs\dispatcher\src\conf.d\enabled_vhosts\aem_author.vhost: A required privilege is not held by the client."

Below is the command to create AEM Project using Maven Archetype 41

mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate \

 -D archetypeGroupId=com.adobe.aem \

 -D archetypeArtifactId=aem-project-archetype \

 -D archetypeVersion=41\

 -D aemVersion=6.5.17 \

 -D appTitle="WKND App" \

 -D appId="wknd-app" \

 -D groupId="com.adobe.aem.guides.wkndapp" \

 -D frontendModule="decoupled"


To avoid this, run the command prompt or terminal as Administrator.

Tuesday, 9 May 2023

AEM as a Cloud Service: Local Setup

Adobe is providing AEM SDK to install it locally.
AEM as a Cloud Service


Follow below steps to install SDK locally and install WKND site.

Navigate to Experience Cloud Software Distribution

Go to the General tab, download the latest Java version.
Experience Cloud Software Distribution

Sunday, 7 May 2023

AEM as a Cloud Service: Dispatcher Setup

Local Dispatcher Setup

Dispatcher Setup

The AEM as a Cloud Service SDK includes a validator tool and docker image for simulating it locally.
 Dispatcher Tools is comprised of:
  • a baseline set of Apache HTTP Web server and Dispatcher configuration files, located in .../dispatcher-sdk-x.x.x/src
  • a configuration validator CLI tool, located at .../dispatcher-sdk-x.x.x/bin/validator
  • a configuration deployment CLI tool, located at .../dispatcher-sdk-x.x.x/bin/docker_run
  • a Docker image that runs Apache HTTP Web server with the Dispatcher module

Thursday, 20 April 2023

AEM Log Tracer: Chrome Plugin


AEM Log Tracer


AEM Log Tracer is a Chrome browser extension that exposes server-side log information per-request in the browser.

AEM Log Tracer collects and exposes per-request:

  1. AEM Logs
  2. Request Progress
  3. Queries executed

Monday, 27 February 2023

Resource dumped by HtmlRenderer - AEM

Noticed below error message on AEM 6.5 author and publish instances.

Resource dumped by HtmlRenderer

Resource path: /content/demo/jcr:content/root/responsivegrid_111/demo/reponsivegrid

Resource metadata: {sling.modificationTime=-1, sling.characterEncoding=null, sling.parameterMap={}, sling.contentType=null, sling.creationTime=-1, sling.contentLength=-1, sling.resolutionPath=/content/demo/jcr:content/root/responsivegrid_111/demo/responsivegrid}

Resource type: nt:unstructured

Resource super type: -

Resource properties

jcr:primaryType: nt:unstructured

jcr:mixinTypes:[cq:replicationStatus]

Above error occurs when empty components of type nt:unstructured are copied using crx/de and are not drag and dropped. After deleting empty responsivegrid component which is copied in crx/de above issue is resolved.

Additionally, this error is observed when we enable a renderer for GET servlet. This can be disabled from the OSGI configMgr.

  • Navigate to felix console's configuration manager 
  • Search for "Apache Sling GET Servlet"
  • Check "Enable HTML" option, if the check box is checked then HTML renderer is enabled for the default GET servlet.
  • Uncheck this checkbox, you notice the 404 page instead of the "Resource dumped by HtmlRendererServlet" message.

Tuesday, 31 January 2023

Create Content Fragment in AEM

What is Content Fragment?

Content Fragments are editorial content, primarily text, and related images. They are pure content, without design and layout. Content fragments are not available in the classic UI. AEM also supports the translation of fragment content. Learn more about content fragments here.

Create Content Fragment Model Configuration:


Before we create content fragment we need to create a content fragment model. AEM configurations allow you to do many things such as editable templates, contextual site configurations, and content fragment configurations.
  1. Go to AEM Start > Tools > General > Configuration Browser > Create
  2. Enter “AEM Quickstart Site” for the title
  3. Check the “Content Fragment Models” checkbox
  4. Click create

Create a DAM Folder

Content fragments are stored in the AEM DAM and are simply treated as an asset like an image or pdf. We will want to create a DAM folder for storing all of our content fragments.
  1. Go to AEM Start > Assets > Files > Create > Folder
  2. Enter the title
  3. Click create

Fetch Content Fragment using AEM Core Components

We have seen how to create a content fragment in the previous post.

Content Fragments can be rendered onto a page by below different ways:
  1. Using AEM core components
  2. Using Custom Sling Model
  3. Using Servlet to access Content Fragment.

Let's see how to render Content Fragment using AEM Core Components.

Enable AEM core components

Create a new project called “aemquickstart” using Adobe’s project archetype. Below is a maven archetype command to use. This will generate a boilerplate project with the latest version of Core Components.
mvn -B archetype:generate 
 -D archetypeGroupId=com.adobe.granite.archetypes 
 -D archetypeArtifactId=aem-project-archetype 
 -D archetypeVersion=23 
 -D aemVersion=cloud 
 -D appTitle="AEM Quickstart" 
 -D appId="aemquickstart" 
 -D groupId="com.aemquickstart" 
 -D frontendModule=general 
 -D includeExamples=n

Run below maven command to install the package in AEM
mvn clean install -PautoInstallPackage

Content fragment and content fragment list core components under ui.apps sub module
  • /aemquickstart/ui.apps/src/main/content/jcr_root/apps/aemquickstart/components/content/contentfragment
  • /aemquickstart/ui.apps/src/main/content/jcr_root/apps/aemquickstart/components/content/contentfragmentlist

Let's add these components on to the page.
  1. Go to AEM Start > Sites > aemquickstart > US > English
  2. Click on the parsys
  3. Click the plus icon
  4. Select Content Fragment
  5. Edit the content fragment
  6. Select the "AEM Book" content fragment that we created in the previous post
  7. Add Title, Description, Release Date and Image elements as shown below.
  8. Save the dialog.

Now we can see the content fragment info on the page.

Fetch Content Fragment using Sling Model

We have seen how to create a content fragment in the previous post.

Content Fragments can be rendered onto a page by below different ways:
  1. Using AEM core components
  2. Using Custom Sling Model
  3. Using Servlet to access Content Fragment.

AEM Cloud Manager

Cloud Manager, part of the Adobe Managed Cloud Services, enables organizations to self-manage Experience Manager in the cloud. It includes a continuous integration and continuous delivery (CI/CD) framework that lets IT teams and implementation partners expedite the delivery of customizations or updates without compromising performance or security.