Microsoft Flow – Single item nested arrays

How often do you see data like this coming out of an action in Microsoft Flow:

      "key1": "value 1",
      "key2": "value 2"
      "key1": "value 3",
      "key2": "value 4"

So often I see people getting the following error:

InvalidTemplate. Unable to process template language expressions in action ‘Compose’ inputs at line ‘1’ and column ‘2469’: ‘The template language expression ‘items(‘Apply_to_each’)?[‘key1′]’ cannot be evaluated because property ‘key1′ cannot be selected. Array elements can only be selected using an integer index. Please see for usage details.’.

What does this error mean?

Obviously, you only wanted to get the Key1’s value from the array and you start to think, why doesn’t this just work?

Did you notice in the data that there were two square brackets around the item?

In my case there will only be 1 array of arrays and therefore I can select just the first item. We need to have a look at my overall flow here.

The apply each is taking my nested array and the apply to each still has to handle the inner array.

Therefore rather than using outputs(‘Compose_2’) I could be using outputs(‘Compose_2’)[0] to get to my array of items. Alternatively, you can also use the first() function




Please leave a comment or feedback

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.