Search code examples
arraysjsonazureazure-logic-appsazure-rm-template

How to convert string to array in azure logic app


I have a logic app with few designer steps to execute the business flow. I am getting the below response from HttpRequest action.

 [{
        "name": "Pradeep",
        "age": 12
    },
    {
        "name": "xyz",
        "age": 15
    }
 ]

After that I have added the foreach action to iterate the above response, but I am getting the below error:

ExpressionEvaluationFailed. The execution of template action 'Iterate_the_success_response_of_the_Main_Function_App' failed: the result of the evaluation of 'foreach' expression '@outputs('Compose_2')' is of type 'String'. The result must be a valid array.

So, can anyone suggest how to convert the above response of HttpRequest action into array


Solution

  • It seems the expression outputs('Compose_2') is string but not array, so the "For each" action can't loop it and shows error message.

    You just need to use expression array(outputs('Compose_2')) instead.