Getting first random item from array

I’m trying to get a random item from an array and already searched the documentation but it keeps failing.

The content of the array is this

And then the function to get the first item is setup like this

However I keep getting a data error at the HTTP get a file module saying Failed to map ‘url’: Function ‘first’ finished with error! Function ‘shuffle’ finished with error! Invalid array.

What am I doing wrong? Any help is much appreciated.

Thanks in advance!

Hello,

I recreated your JSON (aggregator output).

You are missing the map() function in your mapping:

{{first(shuffle(map(1.array; "value")))}}

Your HTTP Get a file module requires a URL so you must use random value of “value” key.

Example scenario-

Hope it helps! Have a nice day, Michal

1 Like