March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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.
^ 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}
]
^ This is from 'Set variable1'
Solved! Go to Solution.
Found a resolution using parameters and introducing it directly to the copy activity. No need for more energy on this ticket.
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.
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'.
BTW, not sure if I sent you what the variable setup looks like:
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
6 | |
2 | |
2 | |
1 | |
1 |