Last active
October 11, 2018 19:59
-
-
Save linkerzx/6569586f7890a9f2069941906e2be24c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def post_to_trigger_send( | |
accessToken: str, | |
triggeredSendDefinitionKey: str, | |
SubscriberKey: str, | |
From: dict, | |
Attributes: dict | |
) -> requests.Response: | |
host = "https://www.exacttargetapis.com" | |
end_point = "/messaging/v1/messageDefinitionSends/key:{triggeredSendDefinitionKey}/send" | |
url = host + end_point.format(triggeredSendDefinitionKey=triggeredSendDefinitionKey) | |
headers = { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer %s" % accessToken | |
} | |
data = { | |
"From": From, | |
"To": { | |
"Address": SubscriberKey, | |
"SubscriberKey": SubscriberKey, | |
"ContactAttributes": { | |
"SubscriberAttributes": Attributes | |
} | |
}, | |
"Options": { | |
"RequestType": "ASYNC" | |
} | |
} | |
req = requests.post( | |
url, | |
headers = headers, | |
data=json.dumps(data) | |
) | |
return req |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment