Expand my Community achievements bar.

SOLVED

AEM Assets HTTP API - expose meta data

Avatar

Level 3

Hi,

 

We are planning to consume AEM DAM assets (mainly documents/images) in a 3rd Party system by leveraging the out of the box HTTP assets API. 

 

However, the existing API does not expose all fields from metadata. For example: My image has title and description set in metadata.

 

beast42_0-1657053174399.png


beast42_0-1657053654156.png

 

 

API response: http://jsonblob.com/993978613842067456 

 

API response does not contain title/description in metadata. Is there a way we can modify the OOTB HTTP api and extend it to have additional fields in response? 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @beast42 ,

You can use sync the metadata approach as suggested by @SantoshSai in Adobe Asset API docs - https://experienceleague.adobe.com/docs/experience-manager-65/assets/extending/mac-api-assets.html?l... 

Also, we have alternative options to expose the asset's metadata as below (Replace the asset path with an asset available in your DAM) :

http://localhost:4502/content/dam/learning/sample.jpg.3.json

http://localhost:4502/content/dam/learning/sample.jpg.infinity.json  

Only Metadata

http://localhost:4502/content/dam/learning/sample.jpg/jcr:content/metadata.3.json 

http://localhost:4502/content/dam/learning/sample.jpg/jcr:content/metadata.infinity.json 

Hope this could help you !!!

Thanks

Shiv

 

Shiv Prakash

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @beast42 ,

Custom properties added to the assets will be fetched by assets API. Such as if you have an additional field as "custom" which is having a value of "customValue" in the metadata node of the asset, when you try to fetch the metadata for the particular asset, it will fetch the additional metadata and will show in the JSON response.

Screen Shot 2022-07-05 at 5.30.31 PM.pngScreen Shot 2022-07-05 at 5.30.57 PM.png

you can see any property starting with dam:*, dc:* are not getting pulled into the JSON response whereas any custom property will be pulled into the response.

Unfortunately Asset HTTP API doesn't have any configurations to allow them.

"The API method updates the metadata properties in the jcr namespace. The updates made using the user interface change the metadata properties in the dc namespace. To sync the metadata values between dc and jcr namespace, you can create a workflow and configure Experience Manager to execute the workflow upon asset edit. Use an ECMA script to sync the required metadata properties. The following sample script synchronizes the title string between dc:title and jcr:title."

You can try the sync metadata approach like below:

  1. You can create a workflow and configure Experience Manager to execute the workflow when the dynamic media workflow completes.
  2. Use an ECMA script to sync the required metadata properties from dam:* to some custom Property.
  3. Read the property in the JSON response and use it wherever required.
  4. The following sample script synchronizes the title string between dc:title and jcr:title.
var workflowData = workItem.getWorkflowData();
if (workflowData.getPayloadType() == "JCR_PATH")
{
var path = workflowData.getPayload().toString();
var node = workflowSession.getSession().getItem(path);
var metadataNode = node.getNode("jcr:content/metadata");
var jcrcontentNode = node.getNode("jcr:content");
if (jcrcontentNode.hasProperty("jcr:title"))
{
var jcrTitle = jcrcontentNode.getProperty("jcr:title");
metadataNode.setProperty("dc:title", jcrTitle.toString());
metadataNode.save();
}
}

Reference: https://experienceleague.adobe.com/docs/experience-manager-65/assets/extending/mac-api-assets.html?l...

Hope that helps!

Regards,

Santosh

Avatar

Level 3

Hi Santosh,

 

Thanks for your reply. It looks like it is returning some "dc:" properties and ignoring others. 

 

For example: Assets API returns "dc:creator" but ignores "dc:title" and "dc:description"

 

beast42_0-1657058072842.png

 

beast42_1-1657058108545.png

 

 

Do you have a list of OOTB metadata field it exposes or ignores?

 

 

Avatar

Community Advisor

@beast42 Unfortunately, I couldn't found those list in documentation, the link I have passed has given sample code snippet which can be mapped to fetch property. You can consider steps to achieve as I mentioned above according to documentation. 

Avatar

Correct answer by
Community Advisor

Hi @beast42 ,

You can use sync the metadata approach as suggested by @SantoshSai in Adobe Asset API docs - https://experienceleague.adobe.com/docs/experience-manager-65/assets/extending/mac-api-assets.html?l... 

Also, we have alternative options to expose the asset's metadata as below (Replace the asset path with an asset available in your DAM) :

http://localhost:4502/content/dam/learning/sample.jpg.3.json

http://localhost:4502/content/dam/learning/sample.jpg.infinity.json  

Only Metadata

http://localhost:4502/content/dam/learning/sample.jpg/jcr:content/metadata.3.json 

http://localhost:4502/content/dam/learning/sample.jpg/jcr:content/metadata.infinity.json 

Hope this could help you !!!

Thanks

Shiv

 

Shiv Prakash