title: How do you accumulate values within a ForEach loop in Mule?
body: <p>I have the below json output:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>{
    "results": [
      {
        "ID": "1",
        "ImageID": "2",
        "Name": "Test1",
        "Owner": "sysadmin",
        "Author": "sysadmin",
        "Creator": "sysadmin"
   },
   {
        "ID": "2",
        "ImageID": "23",
        "Name": "Test2",
        "Owner": "sysadmin",
        "Author": "sysadmin",
        "Creator": "sysadmin"
   }
    ]
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>For each ID in above response, i need to invoke the rest service passing ID as a parameter and the rest service will send me a response back. I have to consolidate all the output into a single json response in mule.
  I have tried using for each and enricher but could not able to build it. Below is the code which i am using.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;foreach doc:name="For Each Loop"&gt;
    &lt;logger level="INFO" message="#[payload]" doc:name="Logger" category="INFO"/&gt;
              &lt;json:json-to-object-transformer doc:name="JSON to Object"/&gt;
     &lt;enricher doc:name="Message Enricher"&gt;
                  &lt;http:request config-ref="SAM" path="/abc/#[payload.ID]" method="GET" doc:name="HTTP"/&gt;
  &lt;enrich target="#[flowVars.ID]" source="#[payload[0].ID]"/&gt;
   &lt;/enricher&gt;
   &lt;logger level="INFO" message="#[flowVars.ID]" doc:name="Logger" /&gt;
   &lt;expression-component doc:name="Expression"&gt;&lt;![CDATA[payload.ID = flowVars.ID;    ]]&gt;&lt;/expression-component&gt; 
   &lt;/foreach&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Kindly help me with the way to fix this !!</p>
  
  <p>Thanks</p>