cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nax
Regular Visitor

Apply to each failed because of foreach expression

Hello, 

 

I have a flow that combines two data bases and appends the combined data into a string value using Initialize Variable. 

Next I use Parse JSON and then post it to my database; however, I am getting this error: 

 

The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON1')' is of type 'Object'. The result must be a valid array.

 

This is my JSON Scheme: 

{
  "type""object",
  "properties": {
    "Guid": {
      "type""string"
    },
    "Worker_ID": {
      "type""string"
    },
    "Clock_In": {
      "type""string"
    },
    "Clock_Out": {
      "type""string"
    }
  }
}
 
Any assistant would be greatly appreciated.
Cheers
 
1 ACCEPTED SOLUTION

Accepted Solutions
Jcook
Super User III
Super User III

Hello @Nax 

 

Apply to each loop will only accept Array types. Your JSON schema body is of type Object.

 

If your data is not an array, you do not need to use an Apply to each.


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





View solution in original post

3 REPLIES 3
Jcook
Super User III
Super User III

Hello @Nax 

 

Apply to each loop will only accept Array types. Your JSON schema body is of type Object.

 

If your data is not an array, you do not need to use an Apply to each.


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





View solution in original post

Nax
Regular Visitor

Whew! That was the solution.

 

I moved the HTTP POST into an Apply to Each with conditions and removed the JSON Schema. Used Expressions and that allowed me to post separate lines of data as individual records.

 

Many thanks! 

Jcook
Super User III
Super User III

Hi @Nax,

 

That is great news! Please mark my post as the solution to help others easily find this if they encounter the same issue.


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (2,406)