title: Azure datafactory v2 Execute Pipeline with For Each
body: <p>I am trying to use "Execute Pipeline" to invoke a Pipe which has a ForEach activity. I get an error.</p>
  
  <ol>
  <li>Json for Execute pipe:</li>
  </ol>
  
  
  
  <pre><code>[
      {
          "name": "pipeline3",
          "properties": {
              "activities": [
                  {
                      "name": "Test_invoke1",
                      "type": "ExecutePipeline",
                      "dependsOn": [],
                      "userProperties": [],
                      "typeProperties": {
                          "pipeline": {
                              "referenceName": "MAIN_SA_copy1",
                              "type": "PipelineReference"
                          },
                          "waitOnCompletion": true
                      }
                  }
              ],
              "annotations": []
          }
      }
  ]
  </code></pre>
  
  <ol start="2">
  <li>Jason for Invoke pipe for each activity : </li>
  </ol>
  
  
  
  <pre><code>[
      {
          "name": "MAIN_SA_copy1",
          "properties": {
              "activities": [
                  {
                      "name": "Collect_SA_Data",
                      "type": "ForEach",
                      "dependsOn": [],
                      "userProperties": [],
                      "typeProperties": {
                          "items": {
                              "value": "@pipeline().parameters.TableNames",
                              "type": "Expression"
                          },
                          "batchCount": 15,
                          "activities": [
                              {
                                  "name": "Sink_SAdata_toDL",
                                  "type": "Copy",
                                  "dependsOn": [],
                                  "policy": {
                                      "timeout": "7.00:00:00",
                                      "retry": 0,
                                      "retryIntervalInSeconds": 30,
                                      "secureOutput": false,
                                      "secureInput": false
                                  },
                                  "userProperties": [
                                      {
                                          "name": "Destination",
                                          "value": "@{pipeline().parameters.DLFilePath}/@{item()}"
                                      }
                                  ],
                                  "typeProperties": {
                                      "source": {
                                          "type": "SqlServerSource",
                                          "sqlReaderQuery": {
                                              "value": "@concat('SELECT * FROM ',item())",
                                              "type": "Expression"
                                          }
                                      },
                                      "sink": {
                                          "type": "AzureBlobFSSink"
                                      },
                                      "enableStaging": false,
                                      "parallelCopies": 1,
                                      "dataIntegrationUnits": 4
                                  },
                                  "inputs": [
                                      {
                                          "referenceName": "SrcDS_StructuringAnalytics",
                                          "type": "DatasetReference"
                                      }
                                  ],
                                  "outputs": [
                                      {
                                          "referenceName": "ADLS",
                                          "type": "DatasetReference",
                                          "parameters": {
                                              "FilePath": "@pipeline().parameters.DLFilePath",
                                              "FileName": {
                                                  "value": "@concat(item(),'.orc')",
                                                  "type": "Expression"
                                              }
                                          }
                                      }
                                  ]
                              }
                          ]
                      }
                  }
              ],
              "parameters": {
                  "DLFilePath": {
                      "type": "string",
                      "defaultValue": "extracts/StructuringAnalytics"
                  },
                  "TableNames": {
                      "type": "array",
                      "defaultValue": [
                          "fom.FOMLineItem_manual"
                      ]
                  }
              },
              "variables": {
                  "QryTableColumn": {
                      "type": "String"
                  },
                  "QryTable": {
                      "type": "String"
                  }
              },
              "folder": {
                  "name": "StructuringAnalytics"
              },
              "annotations": []
          },
          "type": "Microsoft.DataFactory/factories/pipelines"
      }
  ]
  </code></pre>
  
  <p>I get an error: </p>
  
  
  
  <pre><code>[
      {
          "errorCode": "BadRequest",
          "message": "Operation on target Collect_SA_Data failed: The execution of template action 'Collect_SA_Data' failed: the result of the evaluation of 'foreach' expression '@pipeline().parameters.TableNames' is of type 'String'. The result must be a valid array.",
          "failureType": "UserError",
          "target": "Test_invoke1",
          "details": ""
      }
  ]
  </code></pre>
  
  <p>Input: </p>
  
  
  
  <pre><code>"pipeline": {
      "referenceName": "MAIN_SA_copy1",
      "type": "PipelineReference"
  },
  "waitOnCompletion": true,
  "parameters": {
      "DLFilePath": "extracts/StructuringAnalytics",
      "TableNames": "[\"fom.FOMLineItem_manual\"]"
  }
  </code></pre>