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.
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?
Solved! Go to Solution.
Views
Replies
Total Likes
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
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.
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:
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();
}
}
Hope that helps!
Regards,
Santosh
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"
Do you have a list of OOTB metadata field it exposes or ignores?
@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.
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
Views
Like
Replies