Skip to main content
Level 2
Feb 13, 2024 1:18 PM UTC
Solved

How to resolve 500 server error when creating a folder in AEM Headless via react frontend after configuring CORS and CSRF?

I'm working on a headless Adobe Experience Manager (AEM) project with React as the frontend. Just added some CORS and CSRF configurations to handle some other errors I have been encountering. Now getting an error when attempting to create a new folder under /content/dam/my-project/tests via a POST request. Using Assets API to create a folder in a specified location. It leads to an error 500 with AEM logging an AssetException indicating failure to create an asset at the specified path. Here's the error snippet in the error.log:

 

13.02.2024 12:51:16.523 *WARN* [[0:0:0:0:0:0:0:1] [1707828676513] POST /api/assets/my-project/tests/ HTTP/1.1] com.adobe.granite.rest.impl.servlet.PostRequest Exception during request processing.

com.adobe.granite.asset.api.AssetException: Failed to create Asset at path [/content/dam/my-project/tests]

at com.adobe.granite.asset.core.impl.AssetManagerImpl.createAsset(AssetManagerImpl.java:78) [com.adobe.granite.asset.core:2.2.76]

at com.adobe.granite.rest.assets.impl.DefaultAssetPlugin.createAsset(DefaultAssetPlugin.java:98) [com.adobe.granite.rest.assets:1.0.74]

at com.adobe.granite.rest.assets.impl.AssetResourceProvider.create(AssetResourceProvider.java:226) [com.adobe.granite.rest.assets:1.0.74]

 

Any ideas? Or additional tips to troubleshoot? Currently not much in the error logs apart from a 'failure to create asset' error.

Thanks. 

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
MoSa1Accepted solution
Level 2
Feb 13, 2024 3:56 PM UTC

Solved: needed to include 'body: JSON.stringify({'

3 replies

SureshDhulipudi
Community Advisor
Community Advisor
Feb 13, 2024 2:04 PM UTC

Did you check the permission of the service user?

 

 

Pleas make sure that the user or service account making the API request has the necessary permissions to create node/folder/assets in the specified location. You can check this in the user administration section of AEM.

 

 

Is the tests/ node already exist? - Verify that the path /content/dam/my-project/tests

 

Check the server logs for any additional error messages that might give more information about what's causing the issue. Like caused by

 

Translate
Jagadeesh_Prakash
Community Advisor
Community Advisor
Feb 13, 2024 3:50 PM UTC

@mosa1 can you check the user which you are using to create folder in asset location does have permissions to create folder ? 

 

window.btoa(`${AEM_USERNAME}:${AEM_PASSWORD}`)

 

I tried the same in my local using admin user and its working for me  

Translate
MoSa1AuthorAccepted solution
Level 2
Feb 13, 2024 3:56 PM UTC

Solved: needed to include 'body: JSON.stringify({'

Translate