April 1, 2020
Estimated Post Reading Time ~

How to create pages using curl command in CQ / WEM

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 below JAVA code to create pages in CQ.
Create Page
You can use WCM API to create a page in CQ apart from the CURL (Form Post) command mentioned here.

Some code example,

Using resource resolver,

import com.day.cq.wcm.api.PageManager;
ResourceResolver resolver = <Get instance of resource resolver>
<If you have request object then request.getResourceResolver()>
PageManager pm = resolver.adaptTo(PageManager.class);
pm.create(String parentPath, String pageName, String template, String title) throws WCMException

Sling Content Manipulation POST API detail can be found here http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.