Menu

Create AEM Content Package using cURL

Use case

Create an Adobe Experience Manager (AEM) content package using cURL

cURL to create a package

Below is the syntax and a sample command to create an AEM content package using cURL.

curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=create -d packageName=<name> -d groupName=<name>

e.g. curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=create -d packageName=sample-test-package -d groupName=my_packages

After the successful execution of cURL, you will see a successful message.

{"success":true,"msg":"Package created","path":"/etc/packages/my_packages/sample-test-package.zip"}

Successful execution of cURL to create an AEM content package
Successful execution of cURL to create an AEM content package

Now login to AEM CRX package manager [/crx/packmgr] and verify your newly created package. You will see the package is available with the given name under the created group.

AEM package manager
AEM package Manager


Error

You might see some errors while running this cURL on your machine. 

Invoke-WebRequest : Parameter cannot be processed because the parameter name 'u' is ambiguous. Possible matches
include: -UseBasicParsing -Uri -UseDefaultCredentials -UserAgent.
At line:1 char:6
+ curl -u admin:admin -X POST http://localhost:4502/crx/packmgr/service ...
+      ~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand


Resolution 

Add .exe with curl keyword in command. After that, the cURL looks like this.

curl.exe -u admin:admin -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=create -d packageName=sample-test-package -d groupName=my_packages


References

Using cURL in AEM


Insufficient Heap Memory

Issue "Insufficient Heap Memory"

Using 64bit VM settings, min.heap=1024MB, min permgen=256MB, default fork arguments=[-Xmx1024m, -XX:MaxPermSize=256m]

**** WARNING: insufficent heap memory ****
The JVM reports 910 MB but we recommend at least 1024 MB +/- 20
Use your JVM's heap size option (like -Xmx1024M) to set that size.
Will fork a JVM to get enough memory.
********************************************************************************
Available memory below specified limits and low-memory action set to fork, will fork to get enough memory
Not forking JVM as -nofork option is set
Setting properties from file

Resolution

If you have just closed any java program then wait for a few minutes and give chance to garbage collection to remove the unwanted space and clean the Heap memory.

AEM Sling Model injection and annotation

In this article, we will understand what all are the ways to reading authored values of AEM component using sling model in AEM

Using ValueMapValue annotation of package org.apache.sling.models.annotations.injectorspecific

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
private String classStartDateLabel;

Using Inject annotation of package javax.inject


@Inject
@Via("resource")
@Optional
private String classStartDateLabel;


Getter method for this injection


public String getClassStartDateLabel() {
return classStartDateLabel;
}