web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Appending apply to eac...
Power Automate
Unanswered

Appending apply to each JSON Objects to one array

(0) ShareShare
ReportReport
Posted on by 10
I have an 'Apply to each' that runs an HTTP connector several times because it takes a parameter input. The results come out in several JSON results. I need to append all of the JSON results into one array. What can I use to do this please?
Categories:
I have the same question (0)
  • Verified answer
    rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at
    Hi,
     
    Based on the shared image, your result property from the HTTP response is an array, and you would like to combine the result arrays from all responses into a single list. If I misunderstood something, please bring some additional context and I will be glad in provide further support :) 
     
    If my understanding is correct, you can achieve it by initializing an empty array variable at the beginning of your flow, as highlighted in green. By the way, I'm initializing another array variable called source (highlighted in yellow), just to simulate your array outputs within a loop:
     
    Inside your loop, you will need a Compose action, where you use the union() expression for combining two arrays:
     
    In my case, I'm using the expression union(variables('combined_array')item()). From your end, use your array variable as first parameter (text in orange in the expression) and your result property as second (text in blue in the expression). 
     
    After that, still inside the loop, add a Set variable action and assign the outputs from your Compose as value: 
     
    Now it's done. From my end, I also included a second Compose after the loop, just to print the current value of combined_array variable at the end of the flow run:
     
    As expected, the output is a flat array from 1 to 8 (or, in your case, containing all items from the result property from each HTTP response):
     
    I'm also sharing an article that I wrote about how to work with arrays in Power Automate, which can be useful for you or anyone else that finds this thread in the future: http://digitalmill.net/2023/07/12/using-loops-and-accessing-array-elements-in-power-automate/
     
     
    Let me know if it works for you or if you need any additional help!
    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.
     
  • Suggested answer
    SaiRT14 Profile Picture
    1,990 Super User 2025 Season 2 on at
    Initialize an Array Variable:
    Before the "Apply to each" loop, you need to initialize an array variable that will store the appended results.
    Add the "Initialize variable" action and set:
    Name: Choose a name, e.g., FinalArray.
    Type: Select Array.
    Value: Leave the value empty initially.

    Use "Append to array variable" Inside the Loop:
    Inside the "Apply to each" loop (after running your HTTP connector and receiving the JSON result), use the "Append to array variable" action to add the JSON result from each iteration to the array.
    Add the "Append to array variable" action and configure:
    Name: Select the array variable you initialized earlier, e.g., FinalArray.
    Value: Add the JSON response from the HTTP connector in each iteration. You can select the dynamic content of the HTTP connector's JSON response.
    Example:
    json
    Copy code
    body('HTTP')

    Collect the Results:
    Once the loop has completed, the array variable (FinalArray) will contain all of the JSON results from each iteration, appended into a single array.
    You can now use this array variable for further actions (e.g., returning the full array, using it in another HTTP request, etc.).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard