Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-22016

REST API: Can't send email to multiple recipients using to_many parameter

    Details

    • Type: Service Pack Request
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 6.2.2
    • Fix Version/s: 6.2.N
    • Component/s: ACS REST API
    • Labels:
      None
    • Bug Priority:
      Category 2
    • ACT Numbers:

      01017753

      Description

      Description
      When using the action-executions endpoint in the Rest API, there seems to be no way to specify multiple recipients using the to_many parameter.

      • If using an array, e.g. ["test1@alfresco.com", "test2@alfresco.com"], an error is thrown:
        {
            "error": {
                "errorKey": "Could not read content from HTTP request body: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token\n at [Source: (BufferedReader); line: 5, column: 20] (through reference chain: java.lang.Object[0]->org.alfresco.rest.api.model.Action[\"params\"]->java.util.LinkedHashMap[\"to_many\"])",
                "statusCode": 400,
                "briefSummary": "09280005 Could not read content from HTTP request body: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token\n at [Source: (BufferedReader); line: 5, column: 20] (through reference chain: java.lang.Object[0]->org.alfresco.rest.api.model.Action[\"params\"]->java.util.LinkedHashMap[\"to_many\"])",
                "stackTrace": "For security reasons the stack trace is no longer displayed, but the property is kept for previous versions",
                "descriptionURL": "https://api-explorer.alfresco.com"
            }
        }
        
      • Other formats like specifying multiple addresses in a comma-delimited or semicolon-delimited single string (e.g. "test1@alfresco.com, test2@alfresco.com") do not result in an email being sent.

      The email is only sent successfully with the to_many parameter if only a single email address is specified in its string value.

      Steps to reproduce

      1. Configure outbound email with way of inspecting emails after they have left ACS (e.g. using Mailcatcher or DevNull SMTP)
      2. Execute the following call from a Rest client, for example Postman:
        url:
        POST to "https://${host}/alfresco/api/default/public/alfresco/versions/1/action-executions"
        body:
        {
        "actionDefinitionId": "mail",
        "params": {
        "to_many": ["test1@alfresco.com", "test2@alfresco.com"],
        "from": "admin@alfresco.com",
        "subject": "Multiple Recipient Test",
        "text": "Hello World"
        }
        }
        

      Expected Behaviour
      The email should be sent to the two recipients specified in the array.

      Compare the following JavaScript code, which works when executed for example from the JavaScript Console:

      var doc = companyhome.childByNamePath("/Data Dictionary/Email Templates/activities/activities-email.ftl");
      var mail = actions.create("mail");
      
      mail.parameters.to_many = ["testuser1@alfresco.com", "testuser2@alfresco.com"];
      mail.parameters.subject = "test";
      mail.parameters.from = "alfrescotest@alfresco.org";
      mail.parameters.text = "some text";
      
      mail.execute(doc);
      

      Observed Behaviour
      The Rest call receives a response "400 Bad Request", with the following error:

      {
          "error": {
              "errorKey": "Could not read content from HTTP request body: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token\n at [Source: (BufferedReader); line: 5, column: 20] (through reference chain: java.lang.Object[0]->org.alfresco.rest.api.model.Action[\"params\"]->java.util.LinkedHashMap[\"to_many\"])",
              "statusCode": 400,
              "briefSummary": "09280005 Could not read content from HTTP request body: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token\n at [Source: (BufferedReader); line: 5, column: 20] (through reference chain: java.lang.Object[0]->org.alfresco.rest.api.model.Action[\"params\"]->java.util.LinkedHashMap[\"to_many\"])",
              "stackTrace": "For security reasons the stack trace is no longer displayed, but the property is kept for previous versions",
              "descriptionURL": "https://api-explorer.alfresco.com"
          }
      }

        Attachments

          Structure

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ewetchy Elisabeth Wetchy
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Structure Helper Panel