Custom_args在sendgrid V3 API中不起作用,但unique_args发送电子邮件,但在event_callback中不起作用

时间:2018-08-29 08:36:16

标签: sendgrid sendgrid-api-v3

我已使用sendgrid v3 api发送电子邮件。如V3 API文档中所述,我使用custom_args在事件回调中获取我的参数,但它显示了400个错误的请求,而当我使用unique_args时,电子邮件已发送,但事件回调未发送我的unique_args参数。

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"}]}

来自发送网格的事件回调响应为

[{"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"}]

在事件回调响应中我可能需要custom_args,在此响应中,我需要email_msg_id这里缺少什么?

1 个答案:

答案 0 :(得分:1)

在custom_args中,data_type必须为字符串。我使用字符串数据将其固定为 “ custom_args”:{'email_msg_id':'106'}。