Hello, I have a question when updating an asset's metadata using the Assets API in AEM as a Cloud Service.
Currently, if I update metadata that already exists in the standard path /jcr:content/metadata, everything works correctly with this payload:
{ "class": "asset", "properties": { "metadata": { "pruebanumber": 22, "singleline": "Value from API" } } }
The Problem
The problem occurs when I try to update metadata that belongs to a child node named default, whose path would be:
/jcr:content/metadata/default/myField
If that node does not already exist in the asset, the API returns a 403 Forbidden error.
Example of the payload that fails when the default node does not yet exist:
{ "class": "asset", "properties": { "metadata": { "pruebanumber": 22, "pruebasingleline": "Value from API", "default": { "indefault": 1234 } } } }
If I manually create the node or update a field from the asset's Properties in the UI, the default node appears. Then, I can update it via the API without any problems.
What I've Tried
I was able to create nodes using a different path (example with x-www-form-urlencoded😞
POST /content/dam/.../image.png/jcr:content default@TypeHint=nt:unstructured default/myField=...
However, I would like to know if there is a way to update the metadata without the need to create this node first, so that the node is created and updated automatically. After creating the node, updating it this way works because the node already exists.
The Question
Is there an official, supported way in AEM as a Cloud Service to update a metadata property whose parent node (e.g., /metadata/default) doesn't exist yet, and have the API automatically create the missing structure?
Or, in AEM Cloud, is it mandatory that:
The node must exist beforehand,
Or it must be defined in the Metadata Schema,
Or it must be created manually before calling the API.
Essentially, I want to know if the AEM Assets API can create missing nodes within the metadata during a PUT operation, or if I must necessarily ensure that the node exists (via Metadata Schema or some prior process).