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 / Parse JSON from a HTTP...
Power Automate
Answered

Parse JSON from a HTTP Web API to create/update Item in Sharepoint List

(0) ShareShare
ReportReport
Posted on by 32

I'm trying to build a flow that will pull employee data out of our HR system from an HTTP call and then use this data to either create new items or update an existing item in a SharePoint list.

 

My JSON schema is:

 

{
    "type""object",
    "properties": {
        "Employee Id": {
            "type""string"
        },
        "First Name": {
            "type""string"
        },
        "Last Name": {
            "type""string"
        },
        "Work Email": {
            "type""string"
        },
        "Location": {
            "type""string"
        },
        "Department": {
            "type""string"
        },
        "Employment Type": {
            "type""string"
        },
        "Job Role": {
            "type""string"
        },
        "Start Date": {
            "type""string"
        },
        "Reports To": {
            "type""string"
        }
    }
}
 
I'm getting the flowing error when Applying to each to create an item:
ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')' is of type 'Object'. The result must be a valid array.
 
 
Categories:
I have the same question (0)
  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @TomSkelton  does your json schema has one object or array of objects? Can you please share the example json output?

  • Ajinder31 Profile Picture
    530 on at

    Hi @TomSkelton , The JSON schema posted seems to an object instead of an Array. Apply to each action expects an array collections to iterate over. 

    It seems the HTTP call is only return an employee objects not list of employees. Can you confirm what was the expected out from the HTTP call? single object or array of employees.

    --------------------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • TomSkelton Profile Picture
    32 on at

    Untitled.png

  • TomSkelton Profile Picture
    32 on at

    The HTTP call is linked to a query rather than the main data set - would it be better to set this up as pulling in this manner rather than a query?

     

    The output in the photo above does give an array back of all of the employees.

  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @TomSkelton use the output of the json in parse json -> Generate from sample. I think the apply to each needs to use the Result property from the parse json outputs. 

  • TomSkelton Profile Picture
    32 on at

    so this:

    {
        "type""object",
        "properties": {
            "body": {
                "type""object",
                "properties": {
                    "isError": {
                        "type""boolean"
                    },
                    "Status": {
                        "type""integer"
                    },
                    "Message": {
                        "type""string"
                    },
                    "Result": {
                        "type""array",
                        "items": {
                            "type""object",
                            "properties": {
                                "Employee Id": {
                                    "type""string"
                                },
                                "First Name": {
                                    "type""string"
                                },
                                "Last Name": {
                                    "type""string"
                                },
                                "Work Email": {
                                    "type""string"
                                },
                                "Location": {
                                    "type""string"
                                },
                                "Department": {
                                    "type""string"
                                },
                                "Employment Type": {
                                    "type""string"
                                },
                                "Job Role": {
                                    "type""string"
                                },
                                "Start Date": {
                                    "type""string"
                                },
                                "Reports To": {
                                    "type""string"
                                }
                            },
                            "required": [
                                "Employee Id",
                                "First Name",
                                "Last Name",
                                "Work Email",
                                "Location",
                                "Department",
                                "Employment Type",
                                "Job Role",
                                "Start Date",
                                "Reports To"
                            ]
                        }
                    }
                }
            }
        }
    }
  • TomSkelton Profile Picture
    32 on at

    Now getting this error:

    The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']?['Result']' is of type 'Null'. The result must be a valid array.

  • Ajinder31 Profile Picture
    530 on at

    Yes @TomSkelton , Above JSON schema seems correct. Just configure the Apply_to_each action with the Result field to iterate over list of employees.

    Ajinder31_0-1669632792621.png

     


     

  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

    @TomSkelton  it looks correct now, though as you are getting error can you please try using body('Parse_JSON')?['Result'] in apply to each? Also can you please share outputs part screenshot of Parse JSON from flow run?

  • TomSkelton Profile Picture
    32 on at

    that's great - that seems to be doing the trick and populating the list.

     

    I've set this up on a button run just for testing, but i'd like this to move to a scheduled flow.

     

    What would be the steps to check the list for the employee ID field and only update columns if they are blank - i.e. no work email address, or if a job title changes.

     

    And if the employee ID doesn't exist then create new item?

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard