Hello!
I’m having trouble trying to include an input data variable to my JSON string using Python - Requests.
- Trigger: Catch’s hook from a web form
- Action: Consumes API to send a Confirmation email
Input Data
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/eae324db-c074-4f46-992f-9e8c30d73738.png)
Code (Action that sends de confirmation email):
import requests
url = "https://api.trx.icommarketing.com/email"
payload="{ \r\n \"From\": \"Icomm Test demo@demo.com\", \r\n \"To\": \"lucas.vargas@icommkt.com\", \r\n \"Cc\": \"\", \r\n \"Bcc\": \"\", \r\n \"Subject\": \"Hello :)\", \r\n \"Tag\": \"string\", \r\n \"HtmlBody\": \"Cuerpo del correo\", \r\n \"TextBody\": \"Texto plano\", \r\n \"ReplyTo\": \"daniel.alarcon@icommkt.com\", \r\n \"Headers\": s], \r\n \"TrackOpens\": true, \r\n \"TrackLinks\": \"HtmlAndText\", \r\n \"Attachments\": s \r\n { \r\n \"Name\": \"readme.txt\", \r\n \"Content\": \"dGVzdCBjb250ZW50\", \r\n \"ContentType\": \"text/plain\" }, \r\n { \r\n \"Name\": \"report.pdf\", \r\n \"Content\": \"dGVzdCBjb250ZW50\", \r\n \"ContentType\": \"application/octet-stream\" \r\n } \r\n ]\r\n }"
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
'X-Trx-Api-Key': 'PRIVATE KEY'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
When I test the API it works because it sends an email "To\": \"lucas.vargas@icommkt.com\"
However, I want the email to be sent to the person who filled the form using “email” as a dynamic variable.
Hope someone can help me with this case
Regards