使用邮递员在 sendgrid v3 正文中发送动态变量 [英] Sending dynamic variables in sendgrid v3 body using postman
问题描述
我正在尝试使用邮递员使用 v3 API 通过 Sendgrid 发送电子邮件,我在 3 个不同的请求中创建了 3 个单独的变量,我想在一封邮件中传递所有这 3 个变量,因为我在 sendgrid 下面使用过https://api.sendgrid.com/v3/mail/send
身体下方
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
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
}
]
}
但上述格式将邮件正文发送为 {{Variable1}},有人可以帮我解决这个问题吗?
but the above format sending the mail body as {{Variable1}}, can someone help me on this?
推荐答案
据我了解,您想发送多个不同值的请求.
From what I understand of the question you want to send multiple requests with different values.
说,GET 到 https://google.com/q={{search}}
并且您有多个搜索查询(dog、chess、marvel、stackoverflow)
Say, GET to https://google.com/q={{search}}
and you have multiple search queries, (dog, chess, marvel, stackoverflow)
- 在邮递员中创建一个集合
- 向
https://google.com/q={{search}}
添加一个带有必要标头的 GET 请求,然后点击Save
- 创建一个带有标题
search
及其下所有搜索值的 CSV 文件 - 点击新创建集合的运行按钮
- 将
Iterations
字段设置为您拥有的查询数.在本例中为 4 - 查找字段
Data
,选择创建的CSV文件 - 点击
Preview
按钮确保数据被正确提取 - 点击
运行测试
- 您可以在
Postman Console
中查看输出
- Create a collection in postman
- Add a GET request to
https://google.com/q={{search}}
with necessary headers and hitSave
- Create a CSV file with the header
search
and all search values under it - Hit the run button for the newly created collection
- Set the
Iterations
field to the number of queries you have. In this example it is 4 - Look for the field
Data
, select the created CSV file - Ensure the data is correctly being picked up by hitting the
Preview
button - Hit
Run test
- You can view the output in the
Postman Console
打开 Postman 控制台在应用程序菜单中前往查看,然后点击显示 Postman 控制台"或使用键盘快捷键(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.
这篇关于使用邮递员在 sendgrid v3 正文中发送动态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!