Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CQ5 curl commands
Note 1: The following CQ curl commands assumes a admin:admin username and password.
Note 2: For Windows/Powershell users: use two "" when doing a -F cURL command.
Example: -F"":operation=delete""
Note 3: Quotes around name of package (or name of zip file, or jar) should be included.
Uninstall a bundle (use http://localhost:4505/system/console/bundles to access the Apache Felix web console)
curl -u admin:admin -daction=uninstall http://localhost:4505/system/console/bundles/"name of bundle"
Install a bundle
curl -u admin:admin -F action=install -F bundlestartlevel=20 -F
bundlefile=@"name of jar.jar" http://localhost:4505/system/console/bundles
Build a bundle
curl -u admin:admin -F bundleHome=/apps/centrica/bundles/name of bundle -F
descriptor=/apps/centrica/bundles/com.centrica.cq.wcm.core-bundle/name_of_bundle.bnd
http://localhost:4505/libs/crxde/build
Stop a bundle
curl -u admin:admin http://localhost:4505/system/console/bundles/org.apache.sling.scripting.jsp
-F action=stop
Start a bundle
curl -u admin:admin http://localhost:4505/system/console/bundles/org.apache.sling.scripting.jsp
-F action=start
Delete a node (hierarchy) - (this will delete any directory / node / site)
curl -X DELETE http://localhost:4505/path/to/node/jcr:content/nodeName -u admin:admin
Upload a package AND install
curl -u admin:admin -F file=@"name of zip file" -F name="name of package"
-F force=true -F install=true http://localhost:4505/crx/packmgr/service.jsp
Upload a package DO NOT install
curl -u admin:admin -F file=@"name of zip file" -F name="name of package"
-F force=true -F install=false http://localhost:4505/crx/packmgr/service.jsp
Rebuild an existing package in CQ
curl -u admin:admin -X POST http://localhost:4505:/crx/packmgr/service/.json/etc/packages/name_of_package.zip?cmd=build
Download (the package)
curl -u admin:admin http://localhost:4505/etc/packages/export/name_of_package.zip > name of local package file
Upload a new package
curl -u admin:admin -F package=@"name_of_package.zip" http://localhost:4505/crx/packmgr/service/.json/?cmd=upload
Install an existing package
curl -u admin:admin -X POST http://localhost:4505/crx/packmgr/service/.json/etc/packages/export/name of package?cmd=install
Activate
curl -u admin:admin -X POST -F path="/content/path/to/page" -F cmd="activate" http://localhost:4502/bin/replicate.json
Deactivate
curl -u admin:admin -X POST -F path="/content/path/to/page" -F cmd="deactivate" http://localhost:4502/bin/replicate.json
Tree Activation
curl -u admin:admin -F cmd=activate -F ignoredeactivated=true -F onlymodified=true
-F path=/content/geometrixx http://localhost:4502/etc/replication/treeactivation.html
Lock page
curl -u admin:admin -X POST -F cmd="lockPage" -F path="/content/path/to/page" -F "_charset_"="utf-8" http://localhost:4502/bin/wcmcommand
Unlock page
curl -u admin:admin -X POST -F cmd="unlockPage" -F path="/content/path/to/page" -F "_charset_"="utf-8" http://localhost:4502/bin/wcmcommand
Copy page
curl -u admin:admin -F cmd=copyPage -F destParentPath=/path/to/destination/parent -F srcPath=/path/to/source/locaiton http://localhost:4502/bin/wcmcommand
Further Resources:
http://cq-ops.tumblr.com/post/19017053665/useful-curl-commands
http://balawcm.wordpress.com/2013/02/13/curl-it-out-adobe-cq5-curl-commands-and-usage/
@ashwani-sahni

This comment has been minimized.

Show comment
Hide comment
@ashwani-sahni

ashwani-sahni Apr 9, 2013

How can we execute XPATH query using cURL command?

How can we execute XPATH query using cURL command?

@sergeimuller

This comment has been minimized.

Show comment
Hide comment
@sergeimuller

sergeimuller Jun 26, 2013

@ashwani-sahni - Have a look at http://balawcm.wordpress.com/2013/02/13/curl-it-out-adobe-cq5-curl-commands-and-usage/.

I'm not sure about XPATH over curl, but you can run queries against the querybuilder interface if that will help you achieve what's necessary.

If you're not very familiar with querybuilder, ensure that you download Alexander Klimetschek's PDF from http://www.pro-vision.de/de.html#adaptto in the 2011 content.

Owner

sergeimuller commented Jun 26, 2013

@ashwani-sahni - Have a look at http://balawcm.wordpress.com/2013/02/13/curl-it-out-adobe-cq5-curl-commands-and-usage/.

I'm not sure about XPATH over curl, but you can run queries against the querybuilder interface if that will help you achieve what's necessary.

If you're not very familiar with querybuilder, ensure that you download Alexander Klimetschek's PDF from http://www.pro-vision.de/de.html#adaptto in the 2011 content.

@mohiaror

This comment has been minimized.

Show comment
Hide comment
@mohiaror

mohiaror Aug 5, 2014

Hi Sergie,

Is there a way to use curl command to install the subpackages of a package in AEM? Basically, I have a package and it includes two more packages. One of that package has a dependency on another one so that they install one after the other (when I install the main package from package manager). When I tried installing the main package using curl command, it just unwrapped the package and exposed both subpackages but it didn't install them. Is there a way to force install them? Also, will it take care of the dependency of one on another?

Thanks

mohiaror commented Aug 5, 2014

Hi Sergie,

Is there a way to use curl command to install the subpackages of a package in AEM? Basically, I have a package and it includes two more packages. One of that package has a dependency on another one so that they install one after the other (when I install the main package from package manager). When I tried installing the main package using curl command, it just unwrapped the package and exposed both subpackages but it didn't install them. Is there a way to force install them? Also, will it take care of the dependency of one on another?

Thanks

@cpilsworth

This comment has been minimized.

Show comment
Hide comment
@cpilsworth

cpilsworth Aug 8, 2014

Add a -F recursive=true to install sub packages

Add a -F recursive=true to install sub packages

@cpilsworth

This comment has been minimized.

Show comment
Hide comment
@cpilsworth

cpilsworth Aug 8, 2014

If you are using these in shell scripts, you may wish to add --fail so that curl returns an error code if the HTTP status code >= 400

If you are using these in shell scripts, you may wish to add --fail so that curl returns an error code if the HTTP status code >= 400

@alifouad991

This comment has been minimized.

Show comment
Hide comment
@alifouad991

alifouad991 Jan 9, 2015

Hello,
I have mac and i want to install CQ5 adobe i have no idea how to start i search and i can't find any clear install
please if any body knows help me

Thanks a lot

Hello,
I have mac and i want to install CQ5 adobe i have no idea how to start i search and i can't find any clear install
please if any body knows help me

Thanks a lot

@asksmruti

This comment has been minimized.

Show comment
Hide comment
@asksmruti

asksmruti Feb 6, 2015

Hi,
I'm doing some sort of manual work for uploading (both new and modify existing) 'Raw Html Files' on Author instance, then activating those content(template files) .
I was looking for some curl option to upload file but that's working. It's setting up the properties as in old template files. and the pages are also not rendering
To Upload File:
curl -u admin:admin -F "jcr:primaryType=cq:Page" -F "jcr:content/jcr:primaryType=cq:PageContent" -F "jcr:content/jcr:title=New Page" -F "jcr:content/sling:resourceType=geometrixx/components/contentpage" http://localhost:4502/content/geometrixx/en/page
=== This command is creating the required page but not rendering anything. Also the properties are not same as in old template file
Curl Command output is showing as succesful

To activate content:
curl -u admin:admin -X POST -F path="/content/path/to/page" -F cmd="activate" http://localhost:4502/bin/replicate.json
==== Command is returning as 'OK' but it's not activating any of the page

I was referring following site for the commands:

http://www.wemblog.com/2011/09/how-to-create-pages-using-curl-command.html

Would be helpful if you can provide some solution for this. there are loads of template files and manual activity is too much time consuming also high chance of error

Hi,
I'm doing some sort of manual work for uploading (both new and modify existing) 'Raw Html Files' on Author instance, then activating those content(template files) .
I was looking for some curl option to upload file but that's working. It's setting up the properties as in old template files. and the pages are also not rendering
To Upload File:
curl -u admin:admin -F "jcr:primaryType=cq:Page" -F "jcr:content/jcr:primaryType=cq:PageContent" -F "jcr:content/jcr:title=New Page" -F "jcr:content/sling:resourceType=geometrixx/components/contentpage" http://localhost:4502/content/geometrixx/en/page
=== This command is creating the required page but not rendering anything. Also the properties are not same as in old template file
Curl Command output is showing as succesful

To activate content:
curl -u admin:admin -X POST -F path="/content/path/to/page" -F cmd="activate" http://localhost:4502/bin/replicate.json
==== Command is returning as 'OK' but it's not activating any of the page

I was referring following site for the commands:

http://www.wemblog.com/2011/09/how-to-create-pages-using-curl-command.html

Would be helpful if you can provide some solution for this. there are loads of template files and manual activity is too much time consuming also high chance of error

@fredfokan

This comment has been minimized.

Show comment
Hide comment
@fredfokan

fredfokan May 13, 2015

Hello!

I would like to use a curl request called from a scheduler tool like rundeck/jenkins...
Is there a way from your point of view for hiding the password?
I believe using encrypted password from cq5 it could be possible , but have no clue how must be formatted the curl request for doing it to do it....
curl -u admin:$(3456661621623123qw83q8w4qasgasusiwq} ?
Any clue on that ?

Hello!

I would like to use a curl request called from a scheduler tool like rundeck/jenkins...
Is there a way from your point of view for hiding the password?
I believe using encrypted password from cq5 it could be possible , but have no clue how must be formatted the curl request for doing it to do it....
curl -u admin:$(3456661621623123qw83q8w4qasgasusiwq} ?
Any clue on that ?

@bjorns

This comment has been minimized.

Show comment
Hide comment
@bjorns

bjorns Sep 7, 2015

Thanks for this @sergeimuller, I've created a command line tool to simplify administering aem using http. Maybe it's useful for someone else: https://github.com/bjorns/aem-cmd

bjorns commented Sep 7, 2015

Thanks for this @sergeimuller, I've created a command line tool to simplify administering aem using http. Maybe it's useful for someone else: https://github.com/bjorns/aem-cmd

@ronnyfm

This comment has been minimized.

Show comment
Hide comment
@ronnyfm

ronnyfm Sep 18, 2015

Is there a way to do a tree activation to achieve reactivation of already activated pages but ignoring modified pages?

ronnyfm commented Sep 18, 2015

Is there a way to do a tree activation to achieve reactivation of already activated pages but ignoring modified pages?

@gsharp

This comment has been minimized.

Show comment
Hide comment
@gsharp

gsharp Oct 1, 2015

wondering if there is a way to get json instead of xml from the generic GET on the service:

example: http://localhost:4502/crx/packmgr/service.jsp?cmd=ls

I'm getting xml which could work but I need something that gives all packs and their state without knowing the group names.

The end game is to find out which packs are installed vs uploaded.

gsharp commented Oct 1, 2015

wondering if there is a way to get json instead of xml from the generic GET on the service:

example: http://localhost:4502/crx/packmgr/service.jsp?cmd=ls

I'm getting xml which could work but I need something that gives all packs and their state without knowing the group names.

The end game is to find out which packs are installed vs uploaded.

@AnkurAhuja

This comment has been minimized.

Show comment
Hide comment
@AnkurAhuja

AnkurAhuja Feb 8, 2016

I am trying to Automate the SAML Configuration in AEM 6.1,
Has anyone generated the CURL command to Automate the authentication-service keystore and CURL command to Automate the trust store for uploading the Certificate.

I am trying to Automate the SAML Configuration in AEM 6.1,
Has anyone generated the CURL command to Automate the authentication-service keystore and CURL command to Automate the trust store for uploading the Certificate.

@ravilution

This comment has been minimized.

Show comment
Hide comment
@ravilution

ravilution Apr 11, 2016

What is the command to replicate a package that is uploaded and installed. In package manager page if you go to more options there is replicate.

What is the command to replicate a package that is uploaded and installed. In package manager page if you go to more options there is replicate.

@zapts

This comment has been minimized.

Show comment
Hide comment
@zapts

zapts May 12, 2016

Package replication is not best practice. It does not provide a method for uninstallation from the replication receiver servers.

zapts commented May 12, 2016

Package replication is not best practice. It does not provide a method for uninstallation from the replication receiver servers.

@ObjectiveTruth

This comment has been minimized.

Show comment
Hide comment
@ObjectiveTruth

ObjectiveTruth May 18, 2016

FYI, the field name is optional, if its not included it will just name it whatever the bundle is called

Created this quick bash script to install a package if it doesn't exist in crx. (based on this gist)

Hope it helps

ObjectiveTruth commented May 18, 2016

FYI, the field name is optional, if its not included it will just name it whatever the bundle is called

Created this quick bash script to install a package if it doesn't exist in crx. (based on this gist)

Hope it helps

@wildone

This comment has been minimized.

Show comment
Hide comment
@wildone

wildone Jul 1, 2016

have a look at this dudes:
https://github.com/wildone/pyaem
I use this for all automation of deploy, just working on a final touches will release Ansible project for this to make everyones life easier

@gsharp, this is what you are looking for: http://localhost:4502/crx/packmgr/list.jsp
@zapts,that corect use ansible to prep your server
@ravilution, this is how curl -u : -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=replicate

wildone commented Jul 1, 2016

have a look at this dudes:
https://github.com/wildone/pyaem
I use this for all automation of deploy, just working on a final touches will release Ansible project for this to make everyones life easier

@gsharp, this is what you are looking for: http://localhost:4502/crx/packmgr/list.jsp
@zapts,that corect use ansible to prep your server
@ravilution, this is how curl -u : -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=replicate

@wildone

This comment has been minimized.

Show comment
Hide comment
@wildone

wildone Jul 1, 2016

also I am dumping all my Curl links here they will include these and more

https://github.com/paulrohrbeck/aem-links
https://github.com/wildone/aem-links

wildone commented Jul 1, 2016

also I am dumping all my Curl links here they will include these and more

https://github.com/paulrohrbeck/aem-links
https://github.com/wildone/aem-links

@dhughes-xumak

This comment has been minimized.

Show comment
Hide comment
@dhughes-xumak

dhughes-xumak May 24, 2017

@cpilsworth mentioned -F recursive=true. This doesn't seem to be necessary, at least not on AEM 6.1.

Also, if you have a bunch of packages to upload and install, you can put them all in a directory and run:

~$ AEM_PACKAGES_DIR=~/Downloads/aem_packages
~$ AEM_USER_PASS=admin:admin
~$ AEM_HOST_PORT=localhost:4502
~$ for f in $AEM_PACKAGES_DIR/*; do 
     echo "Uploading and installing $f to $AEM_HOST_PORT ($AEM_USER_PASS)" ; 
     curl -u $AEM_USER_PASS -F file=@"$f" -F install=true http://$AEM_HOST_PORT/crx/packmgr/service.jsp ; 
   done

This will iterate over the files in AEM_PACKAGES_DIR and upload/install in listing order. Need to enforce a specific order? Prefix the order-specific packages with a number (eg, 1_aem-service-pkg-wrapper-6.1.SP2.zip and 2_cq-6.1.0-hotfix-10302-1.0.zip).

@cpilsworth mentioned -F recursive=true. This doesn't seem to be necessary, at least not on AEM 6.1.

Also, if you have a bunch of packages to upload and install, you can put them all in a directory and run:

~$ AEM_PACKAGES_DIR=~/Downloads/aem_packages
~$ AEM_USER_PASS=admin:admin
~$ AEM_HOST_PORT=localhost:4502
~$ for f in $AEM_PACKAGES_DIR/*; do 
     echo "Uploading and installing $f to $AEM_HOST_PORT ($AEM_USER_PASS)" ; 
     curl -u $AEM_USER_PASS -F file=@"$f" -F install=true http://$AEM_HOST_PORT/crx/packmgr/service.jsp ; 
   done

This will iterate over the files in AEM_PACKAGES_DIR and upload/install in listing order. Need to enforce a specific order? Prefix the order-specific packages with a number (eg, 1_aem-service-pkg-wrapper-6.1.SP2.zip and 2_cq-6.1.0-hotfix-10302-1.0.zip).

@venkyvikram

This comment has been minimized.

Show comment
Hide comment
@venkyvikram

venkyvikram Jul 10, 2017

Hi there..

Any body could help me out with, counting the number of bundles through the curl command in AEM 6?

Regards,
Venkat

Hi there..

Any body could help me out with, counting the number of bundles through the curl command in AEM 6?

Regards,
Venkat

@nirmaljosehere

This comment has been minimized.

Show comment
Hide comment
@nirmaljosehere

nirmaljosehere Nov 6, 2017

@venkyvikram - You can use curl -u admin:admin http://localhost:4502/system/console/bundles.json to get the information

@venkyvikram - You can use curl -u admin:admin http://localhost:4502/system/console/bundles.json to get the information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment