Use Case For testing (If you are trying to capture certain events or testing something in MSM)
Solution There are various way of creating pages using curl command in CQ Some of them are as follows
1) curl -u admin:admin –F cmd="createPage" -F label="" -F parentPath="/content/geometrixx/en/company" -F template="/apps/geometrixx/templates/contentpage" -F title="new page" http://localhost:4502/bin/wcmcommand
2) 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
3) curl --data jcr:primaryType=cq:page --user admin:admin http://<host>:<port>/content/geometrixx/en/toolbar/test3
And then
curl --data jcr:primaryType=PageContent --user admin:admin http://<host>:<port>/content/geometrixx/en/toolbar/test3/jcr:content
You can also use JAVA code to create pages in CQ.
Sling Content Manipulation POST API detail can be found here http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html
Thanks Henry Seginor, Paul from Adobe for providing this information
Solution There are various way of creating pages using curl command in CQ Some of them are as follows
1) curl -u admin:admin –F cmd="createPage" -F label="" -F parentPath="/content/geometrixx/en/company" -F template="/apps/geometrixx/templates/contentpage" -F title="new page" http://localhost:4502/bin/wcmcommand
2) 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
3) curl --data jcr:primaryType=cq:page --user admin:admin http://<host>:<port>/content/geometrixx/en/toolbar/test3
And then
curl --data jcr:primaryType=PageContent --user admin:admin http://<host>:<port>/content/geometrixx/en/toolbar/test3/jcr:content
You can also use JAVA code to create pages in CQ.
Sling Content Manipulation POST API detail can be found here http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html
Thanks Henry Seginor, Paul from Adobe for providing this information
Hi Yogesh.
ReplyDeleteIs there a similar way to create and maintain users/groups/permissons using curl?
I've been trying to do this using the examples from the Apache Sling homepage, but I get a number of error messages each time.
Did you check http://forums.adobe.com/message/4031201
ReplyDeleteAnd http://sling.apache.org/site/managing-users-and-groups-jackrabbitusermanager.html
You need appropriate bundle for this to work
Or try
curl -u admin:admin -F:status=browser -F_charset_=UTF-8 -Frep:password=test -Frep:userId=yogeshTest -FgivenName=yogesh -FfamilyName=upadhyay http://localhost:4502/libs/cq/security/authorizables/POST
Is there a way to activate a page using cURL?
ReplyDeleteSorry for replying late .. was really busy ... You can use [1] or [2] .. let me know if that helps
Delete[1] curl -u admin:admin -F cmd="Activate" -F path="some page path" http://localhost:4502/bin/replicate.json
[2] curl -u admin:admin -F cmd=activate -F ignoredeactivated=true -F onlymodified=true -F path= http://localhost:4502/etc/replication/treeactivation.html
I'm trying to add a replication agent on the author and getting a response of:
ReplyDeleteMethod POST not supported (405)
The requested URL /bin/wcmcommand resulted in an error in com.day.cq.wcm.core.impl.commands.WCMCommandServlet.
This is the command that I'm sending:
curl -u admin:admin –F cmd="createPage" -F label="publish22" -F title="publish22" -F parentPath="/etc/replication/agents.author" -F template="/libs/cq/replication/templates/agent" https://author.hostname.com/bin/wcmcommand
ok, looks like this works:
ReplyDeletecurl -u admin:admin --data "status=browser&cmd=createPage&label=publish22&title=publish22&parentPath=/etc/replication/agents.author&template=/libs/cq/replication/templates/agent" https://author.hostname.com/bin/wcmcommand
Hi,
ReplyDeleteI am creating page using wcmcommand through jquery and its being created successfully but I am not able to add additional properties in page jcr for example I want to add property fullname:asedd in page jcr. Can you please help me out?
Sujeet,
DeleteYou can also do that using CURL or form post see http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html for example.
Thanks Yogesh...
ReplyDeleteCan you please tell me where can i find curl command?
ReplyDeleteSujeet,
ReplyDeleteFor curl please see http://curl.haxx.se/docs/manpage.html it comes with any Unix based system. For windows you can use something like Wget to do same thing.
Yogesh
Is there any similar way to create packages using curl, I need to pass the value of filters as well through curl.
ReplyDeleteThanks
Rohit Varshney
Check Here if this helps http://www.cqtutorial.com/courses/cq-admin/cq-admin-lessons/cq-maintenance/cq-package-manager
DeleteHow to rename a package using curl ?
ReplyDeleteThanks
Rohit Varshney
Check here http://www.cqtutorial.com/courses/cq-admin/cq-admin-lessons/cq-maintenance/cq-package-manager
DeleteHi.. I am Migrating content from DCTM to CQ.
ReplyDeleteI want to use com.day.cq.wcm.api.Pagemanager in my Java code.
Can you please tell me which jar file can be used ?
You can not use PageManager Jar file outside CQ Context. You have to use CURL service or jackrabbit API. In case you have to find dependency within CQ context for pom.xml then you can use http://HOST:PORT/system/console/depfinder and put your package name.
DeleteHi,
ReplyDeleteI am trying the below curl command to add two filters to a package with in CQ5.4 author, however I am facing errors.
curl -g -u admin:admin -X POST --data _charset_=UTF-8 --data groupName=my_packages --data version=0 --data filter=[{"root":"/apps/test/components/adv","rules":[]},{"root":"/apps/test/components/check-link","rules":[]}] --data packageName=curlpackage-0 --data path=/etc/packages/my_packages/curlpackage-0-0.zip http://localhost:4502/crx/packmgr/update.jsp
Error:{"success":false,"msg":"Could not modify package. Missing value. at character 7
of [{root:/apps/LearnBuild/components/att-advantage,rules:[]},{root:/apps/LearnB
uild/components/check-link,rules:[]}]","path":"/etc/packages/my_packages/curlpac
kage-0-0.zip"}
Can you please help? Please let me know what is missing here. I checked the below links as well, but still need to get this error resolved.
http://www.cqtutorial.com/courses/cq-admin/cq-admin-lessons/cq-maintenance/cq-package-manager
http://aemfaq.blogspot.com/2013/09/creating-package-with-filtersexclusion.html
Hi Yogesh,
ReplyDeleteThanks for the post.
How we do pass DATA TYPE of property using CURL command or a MULTI VALUE property
For example:
I have a MULTI VALUE property whose type in CRX is appearing as "String[]"
How do we do this using CURL. What should I write in CURL command to specify this. Currently by default CURL sets the data type as "String" for everything.
Please check http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html either you can use multiple value for same property or TypeHint
DeleteYogesh,
ReplyDeleteYou are simply awsome !
Yes TypeHint works like charm. Also using TypeHint we can specify the DATATYPE too.
So if I give below parameter with Boolean[] it create multi value
-F "jcr:content/myVar@TypeHint=Boolean[]"
and if I remove [] then it creates single value property
-F "jcr:content/myVar@TypeHint=Boolean"
Example Command:
1) MULTI VALUE
curl -u admin:admin -F "jcr:primaryType=cq:Page" -F "jcr:content/jcr:primaryType=cq:PageContent" -F "jcr:content/myVar@TypeHint=Boolean[]" -F "jcr:content/myVar=true" -F "jcr:content/sling:resourceType=geometrixx/components/contentpage" http://localhost:4502/content/geometrixx/en/rohit2
2) SINGLE VALUE
curl -u admin:admin -F "jcr:primaryType=cq:Page" -F "jcr:content/jcr:primaryType=cq:PageContent" -F "jcr:content/myVar@TypeHint=Boolean" -F "jcr:content/myVar=true" -F "jcr:content/sling:resourceType=geometrixx/components/contentpage" http://localhost:4502/content/geometrixx/en/rohit2