Dissecting data from Postman webhook

33 Views Asked by At

I am receiving data from a postman webhook and I am using a pre-request script to access the request body as outlined in the documentation.

var previousRequest = JSON.parse(globals.previousRequest),
    webhookRequestData = previousRequest.data;

// webhookRequestData contains the data sent to your webhook.
console.log(JSON.stringify(webhookRequestData));

I am receiving the data but the problem is that I can't seem to extract the data I want without getting some type of key error or an invalid JSON error. I need to get all the contact info (name, email, phone, etc.) but the incoming data is formatted in a way that I just can't figure out. here is a sample...

{"{\"fcResponse\":{\"responseData\":{\"cmContact\":{\"ownerType\":\"Franchisee\",\"country\":\"USA\",\"_pickYourDesiredAppointmentDate583732175\":\"\",\"contactFirstName\":\"Sherrie\",\"_vehicleserviceinterest1497622543\":\"Auto Window Tinting\",\"_commercial1827422581\":\"\",\"contactType\":\"Retail Customers\",\"_vehicleEngine1759783270\":\"\",\"_buildingType363061559\":\"\",\"suffix\":\"\",\"_ifThisIsRegardingASpecificServiceYouReceivedWhenDidT1573731334\":\"\",\"areaID\":\"\",\"unsubscribe\":\"Opted Out\",\"cmLeadStatusID\":\"New\",\"state\":\"\",\"_enterYourDesiredAppointmentTime853588546\":\"\",\"contactAddedBy\":\"Web SERVICE\",\"emailIds\":\"[email protected]\",\"areaReferenceId\":\"\",\"bounceEmailStatus\":\"No\",\"_dynamicCoupon188185671\":\"\",\"cmSource3ID\":\"TintWorld.com Quote Request\",\"_emailSignUp1344452027\":\"Yes\",\"_recommendedButDeclined27767687\":\"\",\"cmSource1ID\":\"\",\"_formType1540301458\":\"quote\",\"_vesselType1902339993\":\"\",\"zipcode\":\"\",\"smsUnsubscribeDate\":\"\",\"franchiseeReferenceId\":\"513159907\",\"contactedBySmartScheduler\":\"\",\"_vehicleSubmodel1467066024\":\"\",\"lastContactedField\":\"\",\"contactAddDate\":\"2023-12-08T16:19Z\",\"contactLastName\":\"Anthony\",\"divisionID\":\"\",\"position\":\"\",\"smartSchedulerAppointmentDate\":\"\",\"_vehicleMake139916510\":\"Chevrolet\",\"_vehicleYear1213765475\":\"2012\",\"_vehicleModel427539974\":\"Sonic\",\"extn\":\"\",\"city\":\"\",\"_marine368878106\":\"\",\"contactAddedByReferenceId\":\"2\",\"spamEmailStatus\":\"No\",\"referenceId\":\"205990200\",\"phoneNumbers\":\"12345678910\",\"_automotive2043077692\":\"Auto Window Tinting\",\"faxNumbers\":\"\",\"tenantID\":\"TintWorld92\",\"respondedToSmartScheduler\":\"\",\"bounceReason\":\"\",\"smsUnsubscribe\":\"Opt-In Request not Sent\",\"unsubscribeDate\":\"2023-12-08\",\"_homeType32064006\":\"\",\"franchiseeNo\":\"TN - Memphis - Store076\",\"alternateEmail\":\"\",\"comments\":\"I would like windows tinted all around vehicle\",\"address\":\"\",\"cmSource2ID\":\"Internet\",\"mobileNumbers\":\"\",\"_residential648719965\":\"\",\"_syncid1307531401\":\"\",\"contactModifyDate\":\"\",\"unsubscribeReason\":\"\",\"contactOwnerReferenceId\":\"1705095989\",\"cmLeadSubStatusID\":\"\",\"_vehicleDoors1043267202\":\"4\",\"contactOwnerID\":\"Tint World Store 076 Manager\",\"accountDetails\":{\"emailIds\":\"\",\"accountName\":\"\",\"accountType\":\"\",\"companyAddDate\":\"\",\"referenceId\":\"\"},\"unsubscribeReasonDetail\":\"\",\"divisionReferenceId\":\"\",\"serviceID\":\"Email Communications, Information Email\",\"_requestType2131132030\":\"\",\"_mileageIn633847082\":\"\"}},\"responseStatus\":\"Success\",\"responseId\":\"1525927718\"}}":""}

I've tried using bracket and dot notation to get the data I need with no success. Has anyone seen data formatted this way before? If so, how do I format it in a way that I can use it?

0

There are 0 best solutions below