Expand my Community achievements bar.

Hello, I have a question when updating an asset's metadata using the Assets API in AEM as a Cloud Service.

Avatar

Level 2

Currently, if I update metadata that already exists in the standard path /jcr:content/metadata, everything works correctly with this payload:

json
{
    "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:

json
{
    "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😞

text
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:

  1. The node must exist beforehand,

  2. Or it must be defined in the Metadata Schema,

  3. 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).

2 Replies

Avatar

Level 5

Hi @EstebanTr ,

 

In AEM as a Cloud Service, the Assets API cannot create missing metadata nodes.
If the parent node (like /jcr:content/metadata/default) does not exist, the API will return 403 Forbidden and will NOT create it.

To update metadata inside that node, you must first make sure the node exists.
There are only two supported ways:

Supported Ways

  • Add the field in the Metadata Schema
    - AEM automatically creates metadata/default when properties are saved.
  • Create the node manually or via a POST request before updating it
    - After the node exists, the API updates work normally.

Not Possible

The Assets API cannot auto-create /metadata/default or other missing nodes during a PUT request.

 

You must create the node first. AEM will not create it automatically.

 

Thanks

Vishal

Avatar

Level 2

This behavior is expected in AEM as a Cloud Service. When you update metadata through the UI, AEM automatically creates the required node structure (like /metadata/default) because the UI respects the metadata schema and ensures compliance with the repository model. Once that node exists, the Assets API can update it without issue because the hierarchy is valid.

 

AEM Cloud enforces stricter repository integrity compared to on-prem. It expects the node hierarchy to exist before you update properties.

 

Recommended Approach

  • Define properties in Metadata Schema → ensures nodes exist and are indexed.
  • If dynamic properties are needed:
    • Create the node first via Sling POST or a custom servlet.
    • Then update the property via PUT/PATCH.