Skip to content

Instantly share code, notes, and snippets.

@linkerzx
Last active October 11, 2018 19:59
Show Gist options
  • Save linkerzx/6569586f7890a9f2069941906e2be24c to your computer and use it in GitHub Desktop.
Save linkerzx/6569586f7890a9f2069941906e2be24c to your computer and use it in GitHub Desktop.
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