Use the Submit to REST Endpoint action to post the submitted data to a rest URL. The URL can be of an internal (the server on which the form is rendered) or an external server. 

Typically customer would want to submit the form data to an external server for further processing.

To post data to an internal server, provide a path of the resource. The data is posted the path of the resource. For example, /content/restEndPoint. For such post requests, the authentication information of the submit request is used.

To post data to an external server, provide a URL. The format of the URL is http://host:port/path_to_rest_end_point. Ensure that you configure the path to handle the POST request anonymously.  

For the purpose of this article, I have written a simple war file that can be deployed on your tomcat instance. Assuming your tomcat is running on port 8080, the POST url is going to be

http://localhost:8080/AemFormsEnablement/HandleFormSubmission

when you configure your Adaptive Form to submit to this endpoint, the form data and the attachments if any can be extracted in the servlet by the following code

String formData = request.getParameter("dataXml");

// Form attachments are sent as parts called "attachments". The code below saves an attachments which is of type images/jpg to the file system
request.getPart("attachments").write("c:\\attachments\\formattachment.jpg");

Adaptive Form configured to submit to external end point

Download

To test this on your server please do the following

  1. Install Tomcat if you do not have it already. Instructions to install tomcat are available here
  2. Download the zip file associated with this article. Unzip the file to get the war file. 
  3. Deploy the war file in your tomcat server.
  4. Create a simple Adaptive Form and configure its submit action as shown in the screenshot above. The POST URL is HTTP://localhost:8080/AemFormsEnablement/HandleFormSubmission. If your AEM and tomcat are not running on localhost, please change the URL accordingly.
  5. To enable multipart form data submission to tomcat, please add the following attribute to the context element of the <tomcatInstallDir>\conf\context.xml and restart your Tomcat server.
  6. <Context allowCasualMultipartParsing="true">
  7. Preview your Adaptive Form and submit. Check the tomcat console window for messages.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy