Expand my Community achievements bar.

SOLVED

HTTP API Asset get metadata

Avatar

Level 2

Hi

 

Can the user somehow configure, which metadata fields will be returned via asset API?

I need some additional fields, but unfortunately, I can't see them in returned JSON.

 

Thank you in advance for any tips. 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @marcinn 

 

Have you added the additional matadata to assets? If it's added to the assets, it will be fetched by assets API.

Such as if you have an additional field as "something" which is having a value of "Somevalue" in the metadata node of the asset, when you try to fetch the metadata for the perticular asset, it will fetch the additional metadata and will show in the JSON response.

 

asutosh_j3_0-1618320011705.png

asutosh_j3_1-1618320039726.png

http://localhost:4502/api/assets/wknd-events/wknd-events.jpg.json

 

Thanks!

View solution in original post

7 Replies

Avatar

Correct answer by
Community Advisor

Hi @marcinn 

 

Have you added the additional matadata to assets? If it's added to the assets, it will be fetched by assets API.

Such as if you have an additional field as "something" which is having a value of "Somevalue" in the metadata node of the asset, when you try to fetch the metadata for the perticular asset, it will fetch the additional metadata and will show in the JSON response.

 

asutosh_j3_0-1618320011705.png

asutosh_j3_1-1618320039726.png

http://localhost:4502/api/assets/wknd-events/wknd-events.jpg.json

 

Thanks!

Avatar

Level 2

Hi

 

many thanks for your answer, unfortunately, it doesn't look like in my case. I've added many fields to metadata, but I'm getting only few. 

 

marcinn_0-1618320363356.png

 

but my asset in CRX looks like this

 

marcinn_1-1618320394184.png

I've also Dynamic Media configured there, and frankly speaking, I need few scene7 fields. 

Avatar

Community Advisor

Hi @marcinn 

 

I see you have all the property starting with dam:* any property starting with dam:* are not getting pulled into the JSON response whereas any custom property will be pulled into the response. Can you try it and see if it works for you or not by adding any custom property?

 

Thanks!

Avatar

Level 2

Hi

 

thx for your comment. I did some tests, and you're right additional metadata filed (which I've added) works

marcinn_0-1618378820932.png

 

but unfortunately, I need those values in dam namespace. (especially dam:scene7Domain, dam:scene7Type, 

dam:sceneFile). Any chance to get them from API or from any other way but in JS file?

Avatar

Level 1

Hi @marcinn ,

According to the below link, the asset HTTP API is unable to read metadata from a custom namespace.

https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/assets/admin/mac...

 

Using a simple HTTP API, you can retrieve the complete custom metadata of any asset by accessing the following URL. As this is working for me.

http://localhost:4502/content/dam/we-retail/en/people/womens/women_6.jpg/jcr:content.3.json

Avatar

Community Advisor

Hi @marcinn 

 

Unfortunately there is no such config to allow it.

But 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 custom 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();
}
}

You can try the same steps for your custom property. 

 

Here is the detailed article:

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

 

Hope this helps!

Thanks

 

Avatar

Level 2

This thread is confirming the API can't even return AEM's own metadata fields...?

 

Even the documentation is **bleep** - "To obtain a full representation of the entity, clients should retrieve the contents of the URL pointed to by the link with a rel of self." No mention of only returning custom metadata fields.