Home > database >  Azure Logic App - Create Array with only one object
Azure Logic App - Create Array with only one object

Time:10-17

I am getting data from a powershell script from an automation account. i use this data to create reports and alerts. in 90% of the cases it is an json array.

So in my logic app i am going to parse the json and filter the array afterwards. i use the filtered data to create alerts based of the "id" in the filter. As i said in 90% of the cases this works perfectly.

But, if i only get one object from the script instead of the array i was getting the error:

"message": "Invalid type. Expected Array but got Object."

i solved this on the Parse Json step with:

"type": [
"object",
"array"

]

But now my "filter Array "is obviously not working anymore:

BadRequest. The 'from' property value in the 'query' action inputs is of type 'Object'. The value must be an array.

So i am trying to figure out how to solve this, is it possible to make an if/else statement and check if its an array or object?

Or should i initialize an empty array variable and append the object into the array so the filter will still work?

CodePudding user response:

In the 'From' parameter of your 'Filter array' action, try using the enter image description here

  • Related