sendgridsendgrid-api-v3

Custom_args not working in sendgrid V3 API but unique_args sends email but not in event_callback


I have used sendgrid v3 api for sending emails. As mentioned in documentation of V3 API I use custom_args to get my params in event callback but it shows 400 bad request, while I use unique_args, the email was sent but the event callback does not send my unique_args params.

data = {"content": [{"value": "dfafds", "type": "text/plain"}], "attachments": [{"content": "UEsDBB......QACAgIAAA=", "type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "content_id": "BqzZqz7LaqO9", "filename": "Contactmanager-company.xlsx", "disposition": "attachment"}], "from": {"email": "bishnusyangja@gmail.com"}, "personalizations": [{"to": [{"email": "bishnu@janakitech.com"}], "custom_args": {"email_msg_id": 106}, "subject": "daff"}]}

Event callback response from send grid is

[{"sg_event_id": "aoDNXRAeRuaCAVRiutD-fg",
"sg_message_id": "epJqlw1JThGw--dDTC1oCQ.filter0099p3las1-8681-5B853F95-29.0",
"smtp-id": "epJqlw1JThGw--dDTC1oCQ@ismtpd0006p1maa1.sendgrid.net",
"timestamp": 1535459222,
"email": "bishnu@janakitech.com",
"event": "processed"}]

I need may custom_args in event callback reponse, In this response I need email_msg_id What is missing here ?


Solution

  • In custom_args, data_type must be string. I fixed it using string data as "custom_args": {'email_msg_id': '106'}.