Reputation: 23
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": "[email protected]",
"name": "API Testing"
}
],
"subject": "API testing successful"
}
],
"from": {
"email": "[email protected]",
"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?
Upvotes: 2
Views: 4123
Reputation: 61
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. U also need to pass the (API Key) Authorization as "Authorization: and Value as "Bearer ". In the Request Body pass the personalizations object.
{
"personalizations": [
{
"to": [
{
"email": "ron@***",
}
],
"dynamic_template_data": {
"<variable_name>": <variable_value>
}
}
],
"from": {
"email": "[email protected]",
"name": "Development Team"
},
"content": [
{
"type": "text/html",
"value": "replace body with template content"
}
],
"template_id": "******"
}
Upvotes: 1
Reputation: 350
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)
https://google.com/q={{search}}
with necessary headers and hit Save
search
and all search values under itIterations
field to the number of queries you have. In this example it is 4Data
, select the created CSV filePreview
buttonRun test
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.
Upvotes: 0