I am trying to use an excel spreadsheet as a data source to populate a Word template in Logic Apps; what am I doing wrong?

Bickham, Rodney 1 Reputation point
2021-02-03T15:17:03.78+00:00

I always get an error on merging the dynamic content with the template. I have added a plain text page control to the template and given it the name of a column in the execel file. I have also formatted the excel worksheet data as a table and used the "get table" action. I have also tried the "get worksheet" action. When I try to run it, this the raw input I get

{
  "method": "post",
  "queries": {
    "drive": "b!B29OTtZBAUqDOxf0zBA21I1CuoyQVvxCidgTmJrJJaZVxNBAuDU7R556AA0mz4uK",
    "file": "{\"@odata.id\":\"/drives('b%21B29OTtZBAUqDOxf0zBA21I1CuoyQVvxCidgTmJrJJaZVxNBAuDU7R556AA0mz4uK')/items('01SYYEFWUUAAQHWPSC25DLEXXGTEOMORB4')/workbook/tables(%271%27)\",\"style\":\"TableStyleMedium2\",\"name\":\"Table1\",\"showFilterButton\":true,\"id\":\"1\",\"highlightLastColumn\":false,\"highlightFirstColumn\":false,\"legacyId\":\"1\",\"showBandedColumns\":false,\"showBandedRows\":true,\"showHeaders\":true,\"showTotals\":false}/General/template/IU_Permit.docx",
    "source": "groups/ef7d279f-76f8-4d89-801e-c8deac083eac"
  },
  "path": "/api/templates/getFile",
  "host": {
    "connection": {
      "name": "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/providers/Microsoft.Web/connections/wordonlinebusiness"
    }
  }
}

This is the raw output

{
  "statusCode": 400,
  "headers": {
    "Pragma": "no-cache",
    "x-ms-request-id": "27bfda10-cb04-4403-80aa-6565a1e5d66d",
    "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
    "X-Content-Type-Options": "nosniff",
    "X-Frame-Options": "DENY",
    "Cache-Control": "no-store, no-cache",
    "Set-Cookie": "ARRAffinity=d0f0007dfc4c17851c7abd70ceaf6c0aff65f4f34f6d9c955062f139659f0f03;Path=/;HttpOnly;Secure;Domain=wordonlinebusiness-scus.azconn-scus.p.azurewebsites.net,ARRAffinitySameSite=d0f0007dfc4c17851c7abd70ceaf6c0aff65f4f34f6d9c955062f139659f0f03;Path=/;HttpOnly;SameSite=None;Secure;Domain=wordonlinebusiness-scus.azconn-scus.p.azurewebsites.net",
    "Timing-Allow-Origin": "*",
    "x-ms-apihub-cached-response": "true",
    "Date": "Wed, 03 Feb 2021 15:09:04 GMT",
    "Content-Length": "311",
    "Content-Type": "application/json",
    "Expires": "-1"
  },
  "body": {
    "status": 400,
    "message": "The selected file doesn't contain template elements.\r\nclientRequestId: 27bfda10-cb04-4403-80aa-6565a1e5d66d",
    "error": {
      "message": "The selected file doesn't contain template elements."
    },
    "source": "wordonlinebusiness-scus.azconn-scus.p.azurewebsites.net"
  }
}

This is the code view

{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "actions": {
      "Bring_Data_and_Template_Together": {
        "actions": {
          "Populate_a_Microsoft_Word_template": {
            "inputs": {
              "host": {
                "connection": {
                  "name": "@parameters('$connections')['wordonlinebusiness']['connectionId']"
                }
              },
              "method": "post",
              "path": "/api/templates/getFile",
              "queries": {
                "drive": "b!B29OTtZBAUqDOxf0zBA21I1CuoyQVvxCidgTmJrJJaZVxNBAuDU7R556AA0mz4uK",
                "file": "@{items('Bring_Data_and_Template_Together')}/General/template/IU_Permit.docx",
                "source": "groups/ef7d279f-76f8-4d89-801e-c8deac083eac"
              }
            },
            "runAfter": {},
            "type": "ApiConnection"
          }
        },
        "foreach": "@body('Get_Table_Formatted_Data_in_Excel_File')?['value']",
        "runAfter": {
          "Get_Table_Formatted_Data_in_Excel_File": [
            "Succeeded"
          ]
        },
        "type": "Foreach"
      },
      "Get_Table_Formatted_Data_in_Excel_File": {
        "inputs": {
          "host": {
            "connection": {
              "name": "@parameters('$connections')['excelonlinebusiness']['connectionId']"
            }
          },
          "method": "get",
          "path": "/codeless/v1.0/drives/@{encodeURIComponent('b!B29OTtZBAUqDOxf0zBA21I1CuoyQVvxCidgTmJrJJaZVxNBAuDU7R556AA0mz4uK')}/items/@{encodeURIComponent('01SYYEFWUUAAQHWPSC25DLEXXGTEOMORB4')}/workbook/tables",
          "queries": {
            "source": "groups/ef7d279f-76f8-4d89-801e-c8deac083eac"
          }
        },
        "metadata": {
          "01SYYEFWUUAAQHWPSC25DLEXXGTEOMORB4": "/General/merge/TestBatch.xlsx"
        },
        "runAfter": {},
        "type": "ApiConnection"
      }
    },
    "contentVersion": "1.0.0.0",
    "outputs": {},
    "parameters": {
      "$connections": {
        "defaultValue": {},
        "type": "Object"
      }
    },
    "triggers": {
      "OnceADay": {
        "recurrence": {
          "frequency": "Day",
          "interval": 1
        },
        "type": "Recurrence"
      }
    }
  },
  "parameters": {
    "$connections": {
      "value": {
        "excelonlinebusiness": {
          "connectionId": "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/providers/Microsoft.Web/connections/excelonlinebusiness",
          "connectionName": "excelonlinebusiness",
          "id": "/subscriptions/mySubscriptionId/providers/Microsoft.Web/locations/southcentralus/managedApis/excelonlinebusiness"
        },
        "wordonlinebusiness": {
          "connectionId": "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/providers/Microsoft.Web/connections/wordonlinebusiness",
          "connectionName": "wordonlinebusiness",
          "id": "/subscriptions/mySubscriptionId/providers/Microsoft.Web/locations/southcentralus/managedApis/wordonlinebusiness"
        }
      }
    }
  }
}
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,996 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,016 Reputation points
    2021-02-04T11:46:13.857+00:00

    Hi @Bickham, Rodney

    Welcome to Microsoft Q&A! Thanks for posting the question.

    I will suggest you to review your word document if it has only the supported content control. In unsupported content control and limitation, you will observe this issue.

    0 comments No comments