I am trying to pull a random item out of an array from a json webhook request. I've got the following done:
- create variables rand, listSize, newIndex
- run the webhook request, delay for response
- (works) set rand to:
{{#=}}RANDOM(){{/}} - (works) set listSize to:
{{webhookResponse.body.size}} - (works) set newIndex to:
{{#=}}FLOOR({{listSize}} * {{rand}}){{/}} - (works) verify this index is not a string by setting newIndex again to:
{{newIndex.asNumber}} - (fails) obtain by the new index with:
{{webhookResponse.body.get(newIndex)}
Unfortunately, this doesn't work at all. I've tried variations like:
{{webhookResponse.body.get({{newIndex}})}}
When I just use a raw literal number, it works fine. e.g.,
{{webhookResponse.body.get(0)}} Not really helpful if I'm building a random function, basically.
Am I missing some nuance about the syntax here? Thanks