Webhooks | Custom payload using Liquid | Cant access child object

Solved
SuperM
Here to help

Webhooks | Custom payload using Liquid | Cant access child object

Hi All.

I am using the webhook payload template editor tool and for some reason unknown to me, I can not access the child object "uplink"  I am using the same syntax as per the Meraki Docs.

 

LIQUID:

{
    "alert":"{{alertData.uplink}}"
}

 

The Error I get:

" Failed to load webhook payload template preview. Make sure you're using valid JSON format. ["Body Liquid error: undefined variable uplink"] "

 

 

The uplink value does exist:

 

LIQUID:

 

{
 "alert" : {{alertData | jsonify }}
}

 

 

 

 

JSON:

 

{
  "alert": {
    "uplink": "0"
  }
}

 

 


Example from Meraki docs which I followed to the "T":

https://developer.cisco.com/meraki/webhooks/custom-payload-templates-overview/#overview

Child object properties can also be accessed using the {{foo.bar}} syntax.

LIQUID:

{
    "port":"{{alertData.portNum}}"
}

 

JSON:

{
  "port": "3"
}



Any suggestions would be appreciated, not sure if it is a bug or if I am doing something wrong.

1 Accepted Solution
mlefebvre
Building a reputation

This looks like it would work to me, and validates.

}

"uplink": "{{alertData|dig:"uplink"}}"
}

View solution in original post

3 Replies 3
mlefebvre
Building a reputation

This looks like it would work to me, and validates.

}

"uplink": "{{alertData|dig:"uplink"}}"
}
SuperM
Here to help

@mlefebvrethanks that worked 😊

DexterLaBora
Meraki Employee
Meraki Employee


as @mlefebvre correctly suggested:
https://developer.cisco.com/meraki/webhooks/custom-payload-templates-overview/#dig

The alertData property is ... special. Since every alert contains different properties, its sort of a black box to the template language. So, using the "dig" filter runs a function to pull this info out at runtime. That being said, if the nested property is declared, then using the dot.notation works. 

We can update the documentation to make this more clear. 

Get notified when there are additional replies to this discussion.