Payload of Product Events is wrong format

Hello,

I have written the serverless app to handle product events. However, after deploying the app, when I created the ticket, the payload is not in JSON type. There is something wrong with escape character. This is the payload:
"{\"iparams\":{},\"region\":\"US\",\"data\":{\"ticket\":{\"subject\":\"Testing Create Ticket 2\",\"description\":\"<div style=\\\"font-family:-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif; font-size:14px\\\"><div dir=\\\"ltr\\\">abc</div></div>\",\"is_description_truncated\":false,\"description_text\":\"abc\",\"is_description_text_truncated\":false,\"due_by\":\"2021-06-25T21:00:00Z\",\"fr_due_by\":\"2021-06-23T21:00:00Z\",\"fr_escalated\":false,\"is_escalated\":false,\"fwd_emails\":[],\"reply_cc_emails\":[],\"email_config_id\":null,\"id\":1187,\"group_id\":null,\"product_id\":null,\"company_id\":null,\"requester_id\":69007578371,\"responder_id\":69004826069,\"status\":2,\"priority\":1,\"type\":\"Question\",\"tags\":[],\"spam\":false,\"source\":3,\"tweet_id\":null,\"cc_emails\":[],\"to_emails\":null,\"created_at\":\"2021-06-23T09:50:16Z\",\"updated_at\":\"2021-06-23T09:50:16Z\",\"attachments\":[],\"custom_fields\":{\"cf_fsm_contact_name_1906006\":null,\"cf_fsm_phone_number_1906006\":null,\"cf_fsm_service_location_1906006\":null,\"cf_fsm_appointment_start_time_1906006\":null,\"cf_fsm_appointment_end_time_1906006\":null,\"cf_fsm_customer_signature_1906006\":null,\"cf_custline_1906006\":null,\"cf_custmline_1906006\":null,\"cf_custcbox_1906006\":false,\"cf_custddown_1906006\":null,\"cf_custdep1_1906006\":null,\"cf_custdep2_1906006\":null,\"cf_custdep3_1906006\":null,\"cf_custdate_1906006\":null,\"cf_custnum_1906006\":null,\"cf_custdeci_1906006\":null}},\"requester\":{\"id\":69007578371,\"name\":\"Abc\",\"email\":\"[abc@hmail.com](mailto:abc@hmail.com)\",\"mobile\":null,\"phone\":null,\"language\":\"en\",\"created_at\":\"2021-06-23T09:48:35Z\"}},\"account_id\":\"1906006\",\"domain\":\"[gdfreshdesk.freshdesk.com](http://gdfreshdesk.freshdesk.com/)\",\"event\":\"onTicketCreate\",\"timestamp\":1624441816.141587}"

This doesn’t happen on localhost, as the Test Data in simulation is already in JSON Type. Could you tell me how can I solve this? I cannot test in the real environment, and it’s hard to debug after deploying. Is there any way I can test with the real environment?

Thank you very much

@Nhat_Nguyen,
I think the data which you pasted is in stringify format, you can do JSON.parse to convert it as a JSON object and proceed

Hope it helps

Thanks

2 Likes