Assets API (HTTP) not working as expected | Community
Skip to main content
Nov 4, 2017 9:21 AM UTC
Solved

Assets API (HTTP) not working as expected

Hi all,

I am trying to use the AEM Assets HTTP API (Assets HTTP API ) but having some problems with it.

I'm testing some things using postman. When doing:

POST /api/assets/myFolder/myAsset.png -H"Content-Type: image/png" --data-binary "@myPicture.png"

I get a 201 response back and the asset is created BUT there is no thumbnail. Do I need to do anything extra for this? Can I check somewhere for errors (although the HTTP response is OK)

Second problem. When trying to update the metadata of the Asset:

PUT /api/assets/myfolder/myAsset.png -H"Content-Type: application/json" -d '{"class":"asset", "properties":{"dc:title":"My Asset"}}'

This also gives back an OK response but the property isn't updated.

Anyone here who has experience using this in AEM 6.3? Any suggestions?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Nov 6, 2017 8:18 PM UTC

I took a look at this API - its a limited restful API. For example - to create a folder - use this CURL command --

curl  -u admin:admin POST http://localhost:4502/content/dam/myFolder -H"Content-Type: application/json" -d '{"class":"assetFolder","properties":{"title":"My Folder"}}'

However - i do not think you will get full access to Assets functionality that you will by using the Java AssetManager API.

10 replies

tarunc78167861
Level 2
Apr 3, 2019 8:05 PM UTC

I know I'm a bit late to the party here, but I just figured this out. When attempting to edit metadata you'll need to edit the metadata object that the properties object contains. e.g. "properties":{ "metadata":{"myVar":"Val"} }. So your request body would actually need to be "properties":{"metadata":{"dc:title":"My Asset"}}. This is assuming that the property you created in the metadata scheme is mapped to something like ./jcr:content/metadata/myProperty

Translate
Nov 27, 2017 10:10 AM UTC

Thank you all again for the help.

I started with the tutorial on making a custom endpoint to create assets. However I'm getting these errors while building (mvn clean install)

[INFO] Scanning for projects...

[ERROR] [ERROR] Some problems were encountered while processing the POMs:

[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.felix:org.osgi.core:jar -> duplicate declaration of version 1.4.0 @ line 84, column 21

[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.sling:org.apache.sling.api:jar -> duplicate declaration of version 2.2.4 @ line 110, column 17

[FATAL] Non-resolvable parent POM for com.adobe.cq.sling.upload:upload-bundle:[unknown-version]: Failure to find com.adobe.cq.sling.upload:upload:pom:1.0-SNAPSHOT in https://repo.adobe.com/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of adobe has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 8, column 13

@

[ERROR] The build could not read 1 project -> [Help 1]

[ERROR]

[ERROR]   The project com.adobe.cq.sling.upload:upload-bundle:[unknown-version] (C:\Users\Thomas\Desktop\AEM\upload\pom.xml) has 1 error

[ERROR]     Non-resolvable parent POM for com.adobe.cq.sling.upload:upload-bundle:[unknown-version]: Failure to find com.adobe.cq.sling.upload:upload:pom:1.0-SNAPSHOT in https://repo.adobe.com/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of adobe has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 8, column 13 -> [Help 2]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

Translate
smacdonald2008
Level 10
Nov 7, 2017 10:03 PM UTC

TO perform very basic tasks.

Translate
Nov 7, 2017 10:31 AM UTC

Thank you all for the responses. However, I find it strange that there is (although limited) documented Assets API which seems to not be working.

I know I can get a lot more functionality using the java API but then why is there an HTTP api?

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
Nov 6, 2017 8:18 PM UTC

I took a look at this API - its a limited restful API. For example - to create a folder - use this CURL command --

curl  -u admin:admin POST http://localhost:4502/content/dam/myFolder -H"Content-Type: application/json" -d '{"class":"assetFolder","properties":{"title":"My Folder"}}'

However - i do not think you will get full access to Assets functionality that you will by using the Java AssetManager API.

Translate
smacdonald2008
Level 10
Nov 6, 2017 7:08 PM UTC
smacdonald2008
Level 10
Nov 6, 2017 6:31 PM UTC

I would look at using the AssetManager API within a Servlet to modify Assets. See this article where we show using AssetManager API from within a Servlet.

Adobe Experience Manager Help | Uploading files to Adobe Experience Manager DAM using AssetManager API

Using the AssetManager API - you get the renditions, etc - as shown in this article.

Translate
Nov 6, 2017 5:34 PM UTC

I understand what you mean when regarding to more control. But can't I just use the APi's at hand? There is an Asset API which is enough for what I want to do.

Maybe someone here has used it before?

Translate
smacdonald2008
Level 10
Nov 6, 2017 2:38 PM UTC

If you want to hit an AEM endpoint - you should look at writing a SLing Servlet and use the AssetManager API. You will have much better control and the Java API offers better functionality.

Translate
kautuk_sahni
Employee
Nov 6, 2017 6:28 AM UTC

ukgaurav can you check this?

Translate
Kautuk Sahni