Iterate an array in a webhook response

Rachel Bond January 24, 2025

I'm actually posting the answer to this issue because everywhere I searched ALMOST had the answer but nothing I could find matched what fixed my issue.

 

Issue:

When iterating a webhook response, I am having an issue getting values that only match a specific string.

1 answer

1 accepted

3 votes
Answer accepted
Rachel Bond January 24, 2025

The webhook response I was getting was in JSON and was like what's seen below.

 

"data": [

    {

        "catfood":[]

    },

    {

        "recipe": [

            "ingredient": {

                "type": "gummybears",

                "color": "purple"

            }

        ]

    },

 

    {

        "recipe":[

            "ingredient": {

                "type": "gummybears",

                "color": "blue"

            }

        ]

    },

 

    {

        "recipe":[

            "ingredient": {

                "type": "candycane",

                "color": "redwhite"

            }

        ]

    },

 

    {

        "toothpaste":[]

    },

 

    {

        "recipe":[

            "ingredient":{

                "type": "gummybears",

                "color": "red"

            }

        ]

    }

]

 

My issue was I wanted to pull ONLY the color of gummybears out of this array and below is what I had to do to accomplish this behavior.

 

{{#webhookResponse.body.data}} {{#recipe}} {{#ingredient.match(".*(gummybears).*")}} {{color}} {{/}} {{/}} {{/}}

 

The output this gave me in the end was:

purple blue red

 

I hope this helps someone else in the future, I spent way too many hours on this.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events