Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

HTTP API Asset get metadata

marcinn
Level 2
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
asutosh_jena
Correct answer by
Community Advisor
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

5 Replies
asutosh_jena
Correct answer by
Community Advisor
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

marcinn
Level 2
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. 

asutosh_jena
Community Advisor
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!

marcinn
Level 2
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?
asutosh_jena
Community Advisor
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 🙂