A brief introduction to generating correspondence via HTTP using the Correspondence Manager API.
    1. Download the sample package
    2. Install it onto you AEM Author using package manager

    Download

  1. Whitelist the AEM URL

    1. Navigate to http://localhost:4502/system/console/configMgr
    2. Search for "Adobe Granite CSRF Filter"
    3. Add the following entry in the excluded paths
      • /content/AemFormsSamples/rendercorrespondence
  2. Define the HTTP POST request

    1. Install Postman
    2. Launch Postman from Google Chrome browser
    3. Create a new request. 
      1. Select POST 
      2. Enter the URL: http://localhost:4502/content/AemFormsSamples/rendercorrespondence.html
      3. Under Authorization, select:
        1. Type: Basic Auth
        2. Username: admin
        3. Password: admin
    4. Specify the Body parameters as shown below. Notice the parameters are dataXml and letterName. These parameters are of type "Text". 


  3. Submit the HTTP POST request to AEM

    1. Press "Send" button to issue the configured HTTP POST request to AEM. 
    2. If your request was successfull, a response similar to the following will appear in the Postman window.
      1. Document genreated and saved to c:\CMLetter\48.pdf .
      2. The name of the file (in this case 48.pdf) is randomly generated and will be different in your case.
  4. This was an simple example of showing you how to make POST invocations to generate letters/notices using Correspondence Management.

    In production scenarios the HTTP POST request would be programmatically define rather than using the Postman harness.

    The following code snippet shows extracting request parameters, querying the letter and using the letter service to render the letter.

    // getting the request parameters
    String dataXml = request.getParameter("dataXml");
    String letterName = request.getParameter("letterName");
    
    // querying for the letter
    com.adobe.icc.dbforms.obj.Statement statement = new com.adobe.icc.dbforms.obj.Statement();
    statement.setAttributeName("title");
    statement.setAttributeValue(letterName);
    statement.setOperator(com.adobe.icc.dbforms.obj.Statement.Operator.EQUALS);
    com.adobe.icc.dbforms.obj.Query query = new com.adobe.icc.dbforms.obj.Query();
    java.util.List<com.adobe.icc.dbforms.obj.Statement> statements = new java.util.ArrayList<com.adobe.icc.dbforms.obj.Statement>();
    	statements.add(statement);
    	query.setStatements(statements);
    ...
    
    // rendering letter using the letter service
    
    com.adobe.icc.render.obj.PDFResponseType pdfResponseType = letterRenderService.renderLetter(letterToRender,dataXml,letterRenderOptionsSpec);

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