Sending dynamic variables in sendgrid v3 body using postman

冷暖自知 提交于 2020-02-25 07:01:48

问题


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

but the above format sending the mail body as {{Variable1}}, can someone help me on this?


回答1:


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)

  • Create a collection in postman
  • Add a GET request to https://google.com/q={{search}} with necessary headers and hit Save
  • 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

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.



来源:https://stackoverflow.com/questions/59454229/sending-dynamic-variables-in-sendgrid-v3-body-using-postman

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!