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']))