I’m trying to set up a connection between two CRM systems (Salesforce and HubSpot) through Zapier webhooks. The first system sends JSON data to my webhook that looks like this:
{
"campaignId": 2847591037,
"users": [
{
"user_data": {
"SMS-enabled": true,
"push-notifications": true,
"jobTitle": "MANAGER",
"phoneNumber": "987654321098",
"fullName": "John Anderson",
"prefix": "Dr",
"surname": "Anderson",
"sex": "M",
"accountType": "Premium Customer",
"email-enabled": true,
"firstName": "John",
"lastIP": "192.168.1.100",
"timezone": "GMT+0300",
"overseas": "no",
"isPremium": true,
"emailAddress": "[email protected]",
"userId": 28491
},
"recordId": "a45b7fg8h9j0k1l2m3n4o5p6q7r8s9t0",
"linked_ids": [
"28491",
"[email protected]"
],
"primaryEmail": "[email protected]",
"mainId": "28491"
}
]
}
I’m having trouble accessing the users array in my JavaScript code step. When I try to get the first user object with this code:
var data = JSON.parse(JSON.stringify(inputData));
console.log(data.users[0]);
return data;
I keep getting “TypeError: Cannot read property ‘0’ of undefined”. The Raw Hook seems to receive the JSON correctly but I can’t access the nested array elements. How can I properly handle this webhook data to extract values from users[0]?