Core Form Container - Post Form Data - Submit - Not working in AEM as a cloud | Community
Skip to main content
Level 2
October 30, 2022
Solved

Core Form Container - Post Form Data - Submit - Not working in AEM as a cloud

  • October 30, 2022
  • 2 replies
  • 2613 views

Hi Team,

 

     In AEM as a Cloud (ver 2022.9.8722.20220912T101352Z-220800), we are using the Core Form Container to build a Simple form which contains Form Text, Form Options and a Form Button. On clicking the Submit button, I am getting the below Forbidden error and from my custom log configuration, I could see that my servlet is not getting called and can't able to see any errors related to this in error.log file as well. Since, it is a OOTB core component, not sure on what we are missing here. Could you please help us on how to get these form data to our backend? Thanks.

 

Dialog:

 

Form: 

 

MyServlet:

@8220494(service = Servlet.class, property = { "sling.servlet.methods=" + HttpConstants.METHOD_POST,
"sling.servlet.paths=/bin/myproject/formpoc", "sling.servlet.selectors=formHandler",
"sling.servlet.extensions=html" })
public class GetFormDataPoc extends SlingAllMethodsServlet {

private static final Logger log = LoggerFactory.getLogger(GetFormDataPoc.class);

@9944223
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
log.debug("@@@ Inside doPost of GetFormDataPoc");
}
}

On Submit the form:

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Yes @arunpatidar. Below is the snippet of my Core Form Container configurations. But, on clicking the submit button, I am getting the above said error with no trace of logs in error log and in my custom log and also in browser network tab. My bundle is in active state with my GetFormDataPoc registered in it. Still not sure on what is going wrong here.

 

 


ok, the one I created was to store data in AEM

action="/content/usergenerated/<some-path>/cq-gen1655981669857/"
actionType="foundation/components/form/actions/store"

 

In you case you have to create the above Endpoint (servlet) and use relative path if it in AEM and register with sling resourcetype but not via path otherwise you may have issue when you deploy to cloud.

2 replies

Lokesh_Vajrala
Community Advisor
Community Advisor
October 31, 2022

Here are a few things you can do to troubleshoot the issue: 

  • Check the status of GetFormDataPoc Servlet in the OSGi console. Is it active? 
  • Use the Sling Servlet Resolver to test the servlet path - /bin/myproject/formpoc.formHandler.html with POST Method type.
  • To which path is the form container posting data when you click the submit button? Check this in the browser network tab. 
October 31, 2022

Hi @lokesh_vajrala,

 

Please find the responses inline,

  • Check the status of GetFormDataPoc Servlet in the OSGi console. Is it active?       Yes, the bundle is in Active state with this servlet in it.
  • Use the Sling Servlet Resolver to test the servlet path - /bin/myproject/formpoc.formHandler.html with POST Method type.       

     

  • To which path is the form container posting data when you click the submit button? Check this in the browser network tab.         In the network tab, i cant able to see any calls on submitting the button.

     

    Please let me know if any more information is required, Thanks.
arunpatidar
Community Advisor
Community Advisor
October 31, 2022

Hi,

It seems user don't have write access at /content/usergenerated path, where data is going to be stored.

Arun Patidar
October 31, 2022

Hi @arunpatidar, But I am doing this in my author environment with admin user.

arunpatidar
Community Advisor
Community Advisor
October 31, 2022

Hi,

With admin user, it should work.

Can you check your form container, if all the configurations are correct? 

Arun Patidar