Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

Create Folder Rest API does not set title for the new folder

Avatar

Level 2

Hello,

 

I am using the Rest API to interact with our AEM as a Cloud Service environment.  When I attempt to use the create folder api, I cant get it to set the Title correctly.

 

For instance, I used the following request:

POST https://author-xxxxxx-xxxxxxxx.adobeaemcloud.com/content/dam/myfolder

Request Body (Content Type = application/json):

{
    "class": "assetFolder",
    "properties": {
        "title": "My Folder"
    }
}

 

This creates the folder with the correct name, but does not set the title.  I tried using jcr:title instead of title in the request, still does not set the title.  I even tried dc:title...nothing seems to work.

I even tried to use the API that ends with a wildcard (and uses a multi-part form body), but that one is even worse because it sets the title correctly, but does not use the name request parameter to create folder name (instead using the title request parameter while replacing spaces with underscores).

 

Has anyone been able to get this to work correctly?

 

Thanks,

Phil

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Which API are you using? 
If you are using the "assets API", then your request URL is not correctly formed, you are missing the "/api/assets" part of it.
If you are using the new experimental folders API, you should give it a try in the playground directly: https://developer.adobe.com/experience-cloud/experience-manager-apis/api/experimental/folders/ 

Hope this helps.



Esteban Bustamante

View solution in original post

7 Replies

Avatar

Level 10

Hi @PhillipKo ,

It seems you're encountering an issue with setting the title of a folder when creating it via the AEM REST API. Let's try to troubleshoot and find a solution.

  1. Check API Documentation: First, ensure that you are using the correct API endpoint and request payload. Refer to the official Adobe documentation or API reference to verify the correct syntax for creating a folder with a specific title.

  2. Payload Structure: Make sure the payload structure is correct. In your case, the payload seems appropriate, with "class": "assetFolder" specifying that it's an asset folder and "properties" containing the properties you want to set.

  3. Property Name: The property for the folder's title might vary depending on the AEM version and configuration. While "title" is commonly used, it's worth checking the documentation or inspecting the properties of an existing folder to confirm the correct property name.

  4. Alternative Approach: If setting the title directly doesn't work, you might try updating the folder's properties after creation using a separate API call. This approach involves retrieving the newly created folder's path and then updating its properties, including the title.

  5. Testing with Different Property Names: Since "title", "jcr:title", and "dc:title" didn't work for you, it might be worth experimenting with other potential property names. You could try "name" or "displayName" to see if they have any effect.

  6. Reach Out to Adobe Support: If you've tried different approaches and none of them seem to work, consider reaching out to Adobe Support for assistance. They might be able to provide insights or solutions specific to your AEM environment or configuration.

By exploring these steps and potentially combining different approaches, you should be able to resolve the issue with setting the title of a folder via the AEM REST API.

Avatar

Level 9

Hi @PhillipKo , 

Folders

Folders are like directories as in the traditional file systems. Folder can contain just assets, just folders, or folders and assets. Folders have the following components:

Entities: The entities of a folder are its child elements, which can be folders and assets.

Properties:

  • name is the name of the folder. This is the same as the last segment in the URL path without the extension.
  • title is an optional title of the folder which can be displayed instead of its name.

 

I'm able to set the title for the folder with the following, please validate once with your request.

 

Post http://localhost:4502/api/assets/test/mytestfolder

RequestBody 

{"class":"assetFolder","properties":{"title":"My Test Folder", "jcr:title":"Test Folder"}}
 
sravs_0-1714989355211.png

 

 
This sets both title and jcr:title for the folder. Please refer for more details 

Avatar

Correct answer by
Community Advisor

Which API are you using? 
If you are using the "assets API", then your request URL is not correctly formed, you are missing the "/api/assets" part of it.
If you are using the new experimental folders API, you should give it a try in the playground directly: https://developer.adobe.com/experience-cloud/experience-manager-apis/api/experimental/folders/ 

Hope this helps.



Esteban Bustamante

Avatar

Level 2

Thanks Esteban - you are correct.....I was using /dam/content instead of /api/assets in my URL.  Once I switched that, everything worked as expected.

Avatar

Administrator

@PhillipKo I trust the AEM community has been helpful to you. We look forward to seeing you back as either a learner or a mentor. The community thrives with SMEs like you. Please invite your AEM peers to contribute too. Happy AEM learning!



Kautuk Sahni

Avatar

Level 2

Hi @PhillipKo ,

I could create a folder and set its title with the following postman request using assets http API,

varun_m1_0-1715161864909.png

Authorization is basic with username and password.

I got the below response,

 

{
    "class": [
        "core/response"
    ],
    "properties": {
        "path": "/api/assets/new folder/*",
        "parentLocation": "/api/assets/new%20folder.json",
        "referer": "",
        "isCreate": true,
        "changes": [
            {
                "argument": "/api/assets/new folder/Hello world",
                "type": "created"
            }
        ],
        "location": "/api/assets/new%20folder/Hello%20world.json",
        "status.message": "Created",
        "title": "Content created /api/assets/new folder/*",
        "status.code": 201
    }
}

 

and I could check the folder created in CRXDE Lite,

varun_m1_2-1715162303198.png

This works as expected. Let me know if you need any more information on this.

Avatar

Level 2

Thanks for all the helpful information and guidance everyone!   I am a newbie to developing in the AEM environment and appreciate all the support!