Expand my Community achievements bar.

SOLVED

Assets API (HTTP) not working as expected

Avatar

Former Community Member

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?

1 Accepted Solution

Avatar

Correct answer by
Level 10

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.

View solution in original post

10 Replies

Avatar

Administrator

ukgaurav can you check this?



Kautuk Sahni

Avatar

Level 10

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.

Avatar

Former Community Member

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?

Avatar

Level 10

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 A...

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

Avatar

Correct answer by
Level 10

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.

Avatar

Former Community Member

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?

Avatar

Former Community Member

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

Avatar

Level 2

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