Question

Freemarker syntax for accessing item in array

  • 30 November 2023
  • 0 replies
  • 56 views

Badge

I am trying to create a custom payload for my Webhook destination. The input event payload has an array of items and I always want to access fields in the first item of the array. I am able to successfully test the connection if I only access the first item of the array, but when I try to access properties within that item, I get a configuration error.

 

"${input.events[0].event_type}"

Leads to the error below

There was an issue with sending your test event.
Invalid payload or configuration.

 

But 

"${input.events[0]}"

does not lead to any errors. This suggests that accessing the item using the index works correctly, but I can’t find any documentation out there on how to access the properties within that item.

 

For reference, this is the input event. I redacted some private information. This is an integration between RevenueCat and Amplitude, I need to forward some of this info to another service (Singular) which Amplitude does not have an integration for.


{
"api_key": <redacted>,
"events": [
{
"event_properties": {
"aliases": [
<redacted>
],
"app_id": <redacted>,
"app_user_id": <redacted>,
"cancel_reason": "UNSUBSCRIBE",
"currency": "USD",
"entitlement_id": null,
"entitlement_ids": [
"Default"
],
"environment": "SANDBOX",
"expiration_at": "2023-11-30T17:02:04Z",
"original_app_user_id": <redacted>,
"original_transaction_id": <redacted>,
"period_type": "NORMAL",
"presented_offering_id": null,
"product_id": <redacted>,
"purchased_at": "2023-11-30T16:02:04Z",
"revenue": 0,
"store": "APP_STORE",
"subscriber_attributes": {
"$fbAnonId": <redacted>,
"$idfa": <redacted>,
"$idfv": <redacted>,
"$ip": <redacted>,
"$onesignalId": <redacted>,
"$onesignalUserId": <redacted>
},
"transaction_id": <redacted>
},
"event_type": "cancellation_event",
"insert_id": <redacted>,
"partner_id": "revenuecat",
"platform": "iOS",
"productId": <redacted>,
"revenue": 0,
"time": 1701360394149,
"user_id": <redacted>,
"user_properties": {
"rc_subscription_status": "cancelled"
}
}
],
"options": {
"min_id_length": 5
}
}

 


0 replies

Be the first to reply!

Reply