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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Struggling to insert J...
Power Automate
Suggested Answer

Struggling to insert JSON output into a table

(1) ShareShare
ReportReport
Posted on by 2




I have a parse JSON step, the output looks like this. Some companies can have multiple meters.
 
{
    "body": {
        "CompanyName""TEST",
        "Meters": [
            "190002135555"
        ]
    }
}

I am parsing this data, then trying to insert it into a table using an apply to each.. but it is giving me this error!


Action 'Apply_to_each' failed: The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression ' @{body('ParseJSON_LOA')?['Meters']}' is of type 'String'. The result must be a valid array.

Can someone help me understand how to correctly configure my apply to each to get the data?
 
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    52,938 Super User 2025 Season 2 on at
    Struggling to insert JSON output into a table
     
    While I see the JSON you have, I would need to see exactly the definition in your ParseJSOn. The above looks fine, but if Apply to Each (For Each) thinks its a string, it is either
     
    a) the ParseJSON Schema you gave it states its a string (so check the Meters Type in the definition) does it say array, object or string, my guess is it says string
     
    b) something else you have done has made it a string (I'd have to see the whole flow to understand) its most likely a
     
    c) with anything you can force it to be an array using createArray, by wrapping whatever "property" it is, whether its meters or days, doesn't matter and the output will be an Array even if atm its a string
     
    Unless the Sample you provided to the ParseJSON accidentally said String, I would verify the definition first as I believe that is the problem area, if not use createArray wrapping Meters, in the input for the Apply to Each
     
    Cheers

    If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.

    Thank you!
    Sincerely, Michael Gernaey
  • Suggested answer
    abm abm Profile Picture
    32,852 Most Valuable Professional on at
    Struggling to insert JSON output into a table
    Hi
     
    For screenshots I used the old classic flow designer. Here it is
     
     
     
     
    Above parse json schema is as follows
     
    {
        "type""object",
        "properties": {
            "body": {
                "type""object",
                "properties": {
                    "CompanyName": {
                        "type""string"
                    },
                    "Meters": {
                        "type""array",
                        "items": {
                            "type""string"
                        }
                    }
                }
            }
        }
    }
     
    The last Apply to each 1 loop map the Compose 2 output for the array iteration to get the Meters
     
    Here is my test result:
     
     
     
     
  • Michael E. Gernaey Profile Picture
    52,938 Super User 2025 Season 2 on at
    Struggling to insert JSON output into a table
     
    @abm abm example demonstrates what I said, which is his JSON is an Array, yours is most likely set to string. The rest is all gravvy

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
Tomac Profile Picture

Tomac 532 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 461 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 256

Last 30 days Overall leaderboard