I want to create and delete pages on this author instance using AEM's page manager API with any automation tool like JMeter or RestAssured but I have no idea, how to do it.
After spending some time on the internet (hitting in the dark), I am able to at settings.xml in .m2/settings.xml from this post - https://www.aemquickstart.in/2017/04/cannot-create-maven-project.html
Also, I have below posts
But how do I implement them? I don't have any AEM coding experience.
Any reference, tutorial, GitHub project, sample code which can help me in understanding how to API APIs on hosted AEM application?
Solved! Go to Solution.
Views
Replies
Total Likes
Understanding PageManager API is difficult if you don't have any conceptual knowledge or hands-on experience on AEM, instead of that you can use POSTMAN and CURL commands to create pages.
Use the below command's to create pages, both will work.
curl -u admin:admin -F "jcr:primaryType=cq:Page" -F "jcr:content/jcr:primaryType=cq:PageContent" -F "jcr:content/jcr:title=keysandstrokes" -F "jcr:content/sling:resourceType=geometrixx/components/contentpage" http://localhost:4502/content/geometrixx/en/keysandstrokes
or
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
Reference links for more curl commands:
http://www.coderss.in/aem-curl-commands/
https://hashimkhan.in/aem-adobecq5-code-templates/curl-aem-commands/
Hi @iamjeeva ,
In order to create/delete a page in AEM programatically, take a look at Page Manager API
Code Snippet to create a page in AEM:
private void createPage (ResourceResolver resolver) throws Exception {
String path = "/content/whatever" ;
String pageName = "testpage";
String pageTitle = "Test Page";
String template = "/apps/sample/templates/test";
Page testPage = null;
PageManager pageManager = resolver.adaptTo(PageManager.class);
if (pageManager != null) {
testPage = pageManager.create(path, pageName, template, pageTitle);
}
}
Hey Chitra - I don't want to set it up on local (can you please trim the answer).
I want to know how can I use PageManager API on my hosted AEM instance (not local instance) like this one https://author.dev.demo.adobecqms.net
Can I use this API with Postman? I mean, I fire a POST calls to the AEM REST API and get the pages created.
Thanks for the response, I appreciate it.
Never mind it is resolved, thanks.
Understanding PageManager API is difficult if you don't have any conceptual knowledge or hands-on experience on AEM, instead of that you can use POSTMAN and CURL commands to create pages.
Use the below command's to create pages, both will work.
curl -u admin:admin -F "jcr:primaryType=cq:Page" -F "jcr:content/jcr:primaryType=cq:PageContent" -F "jcr:content/jcr:title=keysandstrokes" -F "jcr:content/sling:resourceType=geometrixx/components/contentpage" http://localhost:4502/content/geometrixx/en/keysandstrokes
or
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
Reference links for more curl commands:
http://www.coderss.in/aem-curl-commands/
https://hashimkhan.in/aem-adobecq5-code-templates/curl-aem-commands/
I tried both, in first curl command I am getting status 500 error
<html>
<head>
<title>Error while processing /libs/wcm/core/content/sites/content/demo-content-pages</title>
</head>
<body>
<h1>Error while processing /libs/wcm/core/content/sites/content/demo-content-pages</h1>
<table>
<tbody>
<tr>
<td>Status</td>
<td><div id="Status">500</div></td>
</tr>
<tr>
<td>Message</td>
<td><div id="Message">org.apache.sling.api.resource.PersistenceException: Unable to commit changes to session.</div></td>
and for the second curl command, I am getting below error
curl -u jeeva-admin:mypassword –F cmd="createPage" -F label="" -F parentPath="/content/content/demo-content-pages/en/newpages" -F template="/apps/demo/templates/defaultpage" -F title="new page curl" https://author.dev.demo.adobecqms.net/bin/wcmcommand
curl: (6) Could not resolve host: –F
curl: (6) Could not resolve host: cmd=createPage
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>405 Method POST not supported</title></head>
<body>
<h1>Method POST not supported</h1>
<p>Cannot serve request to /bin/wcmcommand in com.day.cq.wcm.core.impl.commands.WCMCommandServlet</p>
<h3>Request Progress:</h3>
<pre>
0 TIMER_START{Request Processing}
1 COMMENT timer_end format is {<elapsed microseconds>,<timer name>} <optional message>
6 LOG Method=POST, PathInfo=null
7 TIMER_START{handleSecurity}
292179 TIMER_END{292171,handleSecurity} authenticator org.apache.sling.auth.core.impl.SlingAuthenticator@413fbfeb returns true
292526 TIMER_START{ResourceResolution}
292573 TIMER_END{46,ResourceResolution} URI=/bin/wcmcommand resolves to Resource=ServletResource, servlet=com.day.cq.wcm.core.impl.commands.WCMCommandServlet, path=/bin/wcmcommand
292579 LOG Resource Path Info: SlingRequestPathInfo: path='/bin/wcmcommand', selectorString='null', extension='null', suffix='null'
292579 TIMER_START{ServletResolution}
292582 TIMER_START{resolveServlet(/bin/wcmcommand)}
292592 TIMER_END{9,resolveServlet(/bin/wcmcommand)} Using servlet com.day.cq.wcm.core.impl.commands.WCMCommandServlet
292595 TIMER_END{15,ServletResolution} URI=/bin/wcmcommand handled by Servlet=com.day.cq.wcm.core.impl.commands.WCMCommandServlet
292597 LOG Applying Requestfilters
292602 LOG Calling filter: com.adobe.granite.resourceresolverhelper.impl.ResourceResolverHelperImpl
292609 LOG Calling filter: org.apache.sling.security.impl.ContentDispositionFilter
292612 LOG Calling filter: com.adobe.granite.csrf.impl.CSRFFilter
292620 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
292624 LOG Calling filter: com.adobe.granite.httpcache.impl.InnerCacheFilter
292628 LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
292632 LOG Calling filter: com.adobe.cq.history.impl.HistoryRequestFilter
292806 LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter
292814 LOG Calling filter: com.adobe.fd.core.security.internal.CurrentUserServiceImpl
293054 LOG Calling filter: com.adobe.cq.wcm.core.components.internal.servlets.CoreFormHandlingServlet
293057 LOG Calling filter: com.adobe.granite.optout.impl.OptOutFilter
293064 LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet
293067 LOG Calling filter: com.adobe.cq.social.commons.cors.CORSAuthenticationFilter
293070 LOG Calling filter: com.adobe.livecycle.dsc.clientsdk.internal.ResourceResolverHolderFilter
293073 LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
293076 LOG Calling filter: com.adobe.livecycle.content.appcontext.impl.AppContextFilter
293080 LOG Calling filter: org.demo.core.filters.LoggingFilter
293136 LOG Calling filter: org.demo.core.filters.LoggingFilter
293148 LOG Calling filter: org.demo.core.filters.LoggingFilter
293159 LOG Calling filter: org.demo.core.filters.LoggingFilter
293171 LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter
293174 LOG Calling filter: com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl
293572 LOG Calling filter: com.adobe.granite.rest.assets.impl.AssetContentDispositionFilter
293575 LOG Calling filter: com.adobe.granite.requests.logging.impl.RequestLoggerImpl
293579 LOG Calling filter: com.adobe.granite.rest.impl.servlet.ApiResourceFilter
293611 LOG Calling filter: com.day.cq.dam.core.impl.assetlinkshare.AdhocAssetShareAuthHandler
293614 LOG Calling filter: com.day.cq.dam.core.impl.servlet.ActivityRecordHandler
293625 LOG Calling filter: com.adobe.cq.social.ugcbase.security.impl.SaferSlingPostServlet
293630 LOG Calling filter: com.day.cq.wcm.core.impl.warp.TimeWarpFilter
293637 LOG Applying Componentfilters
293639 LOG Calling filter: com.day.cq.personalization.impl.TargetComponentFilter
293643 LOG Calling filter: com.day.cq.wcm.core.impl.page.PageLockFilter
293647 LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
293766 LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
293770 TIMER_START{com.day.cq.wcm.core.impl.commands.WCMCommandServlet#0}
293797 LOG Applying Error filters
293800 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
293802 LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
293806 TIMER_START{handleError:status=405}
294527 TIMER_END{719,handleError:status=405} Using handler /apps/sling/servlet/errorhandler/default.jsp
306519 LOG Found processor for post processing ProcessorConfiguration: {contentTypes=[text/html], order=1, active=true, valid=true, processErrorResponse=true, pipeline=(generator=Config(type=htmlparser, config={}), transformers=(Config(type=linkchecker, config={}), Config(type=versioned-clientlibs, config={}), serializer=Config(type=htmlwriter, config={}))}
306709 TIMER_END{306708,Request Processing} Dumping SlingRequestProgressTracker Entries
</pre>
<hr>
<address>Apache Sling</address>
</body>
</html>
Can you please help in finding, what wrong I am doing?
Hi @iamjeeva
You can look into the Page manager api sample examples. Here is the refrence : https://www.programcreek.com/java-api-examples/?api=com.day.cq.wcm.api.PageManager
Thanks,
Nupur
Views
Likes
Replies
Views
Likes
Replies