I'm trying to recreate this CURL request in Python and get it to loop through a CSV.
curl -X "DELETE" --user 'api:<my-api-key>' \ https://api.mailgun.net/v3/messages.thewebsite/unsubscribes \
-F address='email@gmail.com'
I'm thinking I should create a function and return the result. I'm using the requests package along with CSV but getting the output of
<function remove_suppression at 0x7fb3935baf70> printed to the console. What am I missing here?
Code sample below.
Import csv
Import requests
def remove_suppression():
return requests.delete(
"https://api.mailgun.net/v3/messages.thewebsite.com/unsubscribes",
auth=("api", "key-abcdefg12345789gbb"),
data={'address':'row[1]'})
with open('/Users/brett/Downloads/example.csv',newline='') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
try:
remove_suppression()
print("=========================")
print(remove_suppression.text)
sleep(5)
except:
#write log to a text file