【问题标题】:dynamic_template_data not working when sending dynamic template using curl request - Sendgrid API使用 curl 请求发送动态模板时 dynamic_template_data 不起作用 - Sendgrid API
【发布时间】:2020-04-08 14:26:16
【问题描述】:

我正在发出 curl 请求以发送带有把手的动态模板,但它无法正常工作。

curl --request POST \
  --url https://api.sendgrid.com/v3/mail/send \
  --header 'Authorization: Bearer SG.xxxxxxxx.v-8xxxxxxxxxxxxI' \
  --header 'Content-Type: application/json' \
  --data '{"personalizations": [{"to": [{"email": "mrrobot@mail.com"}]}],"from": {"email": "contact@evilcorp.com"},"dynamic_template_data":{"fname":"elliot"}, "subject": "Hello, World!","content": [{"type": "text/html", "value": "Heya!"}], "template_id" : "d-xxxxxxxxxa1f"}}'

在我的动态模板中,我将 fname 用作 {{fname}},但是当我发出 curl 请求时,它却是空的。

【问题讨论】:

    标签: email curl sendgrid sendgrid-api-v3


    【解决方案1】:

    dynamic_template_data 应在 个性化 内。 例如:

    {
      "personalizations": [
        {
          "to": [
            {
              "email": "mrrobot@mail.com"
            }
          ],
          "dynamic_template_data": {
            "fname": "elliot"
          }
        }
      ],
      "from": {
        "email": "contact@evilcorp.com"
      },
      "subject": "Hello, World!",
      "content": [
        {
          "type": "text/html",
          "value": "Heya!"
        }
      ],
      "template_id": "d-xxxxxxxxxa1f"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多