I am trying to iterate through a JSON
array which has been encoded to a string for the purpose of storing on a queue. However, I receive the following error message:
{"code":"ExpressionEvaluationFailed","message":"The execution of template action 'For_each' failed: The result '[{\"Foo\":\"Bar\"}]' of the evaluation of 'foreach' action expression '@{json(decodeBase64(triggerBody()['ContentData']))}' is not a valid array."}
The following is the string being parsed: [{"Foo":"Bar"}]
I have no problems parsing a JSON
string when it is not in an array, for example: {"Foo":"Bar"}
This parses just fine when I am not using a For_each
.
How do I get the logic app to read this as an array?
The issue here is that you are using string interpolation (where expressions are wrapped in @{ ... }) that evaluates to a string representation of the array. Hence evaluation of the 'foreach' expression fails.
You want the expression to be @json(decodeBase64(triggerBody()['ContentData']))
json(decodeBase64(body('HTTP')?['$Content']))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.