Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
PWTRyanWhite
Frequent Visitor

The execution of template action 'MainForEach1' failed: the result of the evaluation of 'foreach'

Hi,

 

I'm trying to setup a pipeline that will take a JSON example and pass it through a for-each loop that will be used to post to a API URL. Below is the setup I have intially created. Keep in mind, the for-each loop does work when passing none complex JSON to the loop. 

 

PWTRyanWhite_0-1725987080261.pngPWTRyanWhite_1-1725987121048.png

PWTRyanWhite_2-1725987217144.png

^ above is 'Set Variable2'

 

This is the JSON I am using to pass to the loop

 

[
  {"lane_id": "SEA-MFR", "origin": "SEA", "destination": "MFR", "input_miles": 688},
  {"lane_id": "GSP-GSP", "origin": "SEA", "destination": "GSP", "input_miles": 287},
  {"lane_id": "RDU-RDU", "origin": "RDU", "destination": "RDU", "input_miles": 103},
  {"lane_id": "WGO-WGO", "origin": "WGO", "destination": "WGO", "input_miles": 422},
  {"lane_id": "BWI-BWI", "origin": "BWI", "destination": "BWI", "input_miles": 433},
  {"lane_id": "JAX-JAX", "origin": "JAX", "destination": "JAX", "input_miles": 464},
  {"lane_id": "GSP-GSP", "origin": "GSP", "destination": "GSP", "input_miles": 275},
  {"lane_id": "MDT-MDT", "origin": "MDT", "destination": "MDT", "input_miles": 688},
  {"lane_id": "MOB-MOB", "origin": "MOB", "destination": "MOB", "input_miles": 749},
  {"lane_id": "BOS-BOS", "origin": "BOS", "destination": "BOS", "input_miles": 799},
  {"lane_id": "CLT-CLT", "origin": "CLT", "destination": "CLT", "input_miles": 235},
  {"lane_id": "WGO-WGO", "origin": "WGO", "destination": "WGO", "input_miles": 434},
  {"lane_id": "PHL-PHL", "origin": "PHL", "destination": "PHL", "input_miles": 528}
]

 

 

PWTRyanWhite_3-1725987359874.png

^ This is from 'Set variable1'

 

1 ACCEPTED SOLUTION

Found a resolution using parameters and introducing it directly to the copy activity. No need for more energy on this ticket.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @PWTRyanWhite 

 

According to the screenshot you provided, the error message for Set Variable2 indicates that the expression type you used in the "Set Variable2" step was a string, but the field expected an object type.

 

If your current expression returns a string, you can try using the json() function to convert the string into an object.

 

Suppose the expression you use in "Set Variable2" is:

 

@variables('Variable1')

 

You can try changing it to:

 

@json(variables('Variable1'))

 

The process might look something like this:

 

Set Variable1 stores JSON data.

 

@json(
'[
{"lane_id": "SEA-MFR", "origin": "SEA", "destination": "MFR", "input_miles": 688}, 
{"lane_id": "GSP-GSP", "origin": "SEA", "destination": "GSP", "input_miles": 287}
]'
)

 

Set Variable2 processes or converts data.

 

@json(variables('Variable1'))

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Found a resolution using parameters and introducing it directly to the copy activity. No need for more energy on this ticket.

Anonymous
Not applicable

Hi @PWTRyanWhite 

 

Thank you for sharing, if you have any questions, please continue to let us know in the forum!

 

Regards,

Nono Chen

Unfortunately, after changing to the @Json format, I am getting this error: The variable 'mind_SYMBOL' of type 'String' cannot be initialized or updated with value of type 'Array'. The variable 'mind_SYMBOL' only supports values of types 'String'.

 

PWTRyanWhite_0-1726071557037.png

 

BTW, not sure if I sent you what the variable setup looks like:

 

PWTRyanWhite_1-1726071624667.png

 

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Free Fabric Certifications

Free Fabric Certifications

Get Fabric certified for free! Don't miss your chance.

January Fabric Update Carousel

Fabric Monthly Update - January 2026

Check out the January 2026 Fabric update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.