{tocify} $title={Table of Contents}
Issue
Got below error while executing a Liquid map inside a Logic App.
Liquid error: Object of type 'System.Collections.Generic.List`1[System.Object]' cannot
be converted to type 'System.String'
Why It happened
In the Liquid map, I have mapped a property as below
"type" : "{{item.extension}}"
However, in the input message the extension is coming as below
"extension": [
"tif"
],
If you see, the input is in form of array/list/collection and am trying to map
it to the type property as a string(using double quotes).
And this is what the error says - that it cannot convert list into string.
What to do
As the input coming is in the form of array (although it will always have a
single value), it needs to be specified that we need to assign the first
value from the array.
In Liquid map we can make use of shorthand functions and here we will
use first shorthand function - which returns the first item of an array.
"type" : "{{item.extension.first}}"
That's it, with this expression the first value of the array will be assigned
to type.
Learn More about Liquid Map - Getting started with Logic App : Liquid Map