[英]Sending dynamic variables in sendgrid v3 body using postman
I am trying to send the emails via Sendgrid using v3 API using postman, I have created 3 separate variables in 3 different requests, I want to pass all those 3 variables in a single mail, for that I have used below sendgrid https://api.sendgrid.com/v3/mail/send
我正在尝试使用 v3 API 使用 postman 通过 Sendgrid 发送电子邮件,我在 3 个不同的请求中创建了 3 个单独的变量,我想在一封邮件中传递所有这 3 个变量,因为我在下面使用了 sendgrid
https://api.sendgrid.com/v3/mail/send
with below body身体下方
{
"personalizations": [
{
"to": [
{
"email": "testing@test.com",
"name": "API Testing"
}
],
"subject": "API testing successful"
}
],
"from": {
"email": "noreply@testApi.com",
"name": "API Testing"
},
"content": [
{
"type": "text/plain",
"value": "{{variable1}}" //In variable1 has a dynamic values
}
]
}
but the above format sending the mail body as {{Variable1}}, can someone help me on this?但是上述格式将邮件正文发送为 {{Variable1}},有人可以帮我吗?
From what I understand of the question you want to send multiple requests with different values.根据我对您要发送具有不同值的多个请求的问题的理解。
Say, GET to https://google.com/q={{search}}
and you have multiple search queries, (dog, chess, marvel, stackoverflow)说,GET 到
https://google.com/q={{search}}
并且你有多个搜索查询,(狗,国际象棋,奇迹,stackoverflow)
https://google.com/q={{search}}
with necessary headers and hit Save
https://google.com/q={{search}}
添加一个带有必要标题的 GET 请求,然后点击Save
search
and all search values under itsearch
及其下的所有搜索值创建一个 CSV 文件Iterations
field to the number of queries you have.Iterations
字段设置为您拥有的查询数。 In this example it is 4Data
, select the created CSV fileData
,选择创建的 CSV 文件Preview
buttonPreview
按钮确保正确获取数据Run test
Run test
Postman Console
Postman Console
查看输出 To open Postman Console Head to View in the application menu, and click on "Show Postman Console" or use the keyboard shortcut (CMD/CTRL + ALT + C) to open.
Head to View in the application menu, and click on "Show Postman Console" or use the keyboard shortcut (CMD/CTRL + ALT + C) to open.
打开 Postman Console Head to View in the application menu, and click on "Show Postman Console" or use the keyboard shortcut (CMD/CTRL + ALT + C) to open.
For handlebar {{ variable_value }} substitutions in dynamic HTML templates, u need to pass the variable value as JSON structure with the key as "dynamic_template_data" as part of personalizations.对于动态 HTML 模板中的车把 {{ variable_value }} 替换,您需要将变量值作为 JSON 结构传递,并将键作为“dynamic_template_data”作为个性化的一部分。 U also need to pass the (API Key) Authorization as "Authorization: and Value as "Bearer ". In the Request Body pass the personalizations object.
U 还需要将(API 密钥)授权传递为“授权:”并将值传递为“承载”。在请求正文中传递个性化 object。
{
"personalizations": [
{
"to": [
{
"email": "ron@***",
}
],
"dynamic_template_data": {
"<variable_name>": <variable_value>
}
}
],
"from": {
"email": "development@crosspaymt.com",
"name": "Development Team"
},
"content": [
{
"type": "text/html",
"value": "replace body with template content"
}
],
"template_id": "******"
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.