Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %%[
- /* Get Subscribers Email Address */
- SET @email = RequestParameter("EmailAddress")
- /* Get Access token using API creds */
- Var @body, @callstatus, @response
- Set @body = '{"clientId": "xxxxxx", "clientSecret": "yyyyyy"}'
- HTTPPost2("https://auth.exacttargetapis.com/v1/requestToken", "application/json", @body, True, @callstatus, @response)
- ]%%
- <script runat="server">
- // Load response into SSJS for parsing
- Platform.Load("Core", "1")
- // get JSON from callstatus
- var callstatus = Variable.GetValue("@callstatus");
- // Parse the string to JSON
- callstatus = Platform.Function.ParseJSON(callstatus);
- // Get Access Token
- Variable.SetValue("@access_token",'BEARER ' + callstatus.accessToken);
- </script>
- %%[
- /* Trigger the Journey via API event */
- Set @body = '{"ContactKey": @email, "EventDefinitionKey":"APIEvent-ad292469-4d77-17a9-e56d-b791b29b8b95", "EstablishContactKey": true, "Data": {"EmailAddress":@email}}'
- HTTPPost2("https://auth.exacttargetapis.com/interaction/v1/events", "application/json", @body, True, @callstatus, @response, 'Authorization', @access_token)
- ]%%
Add Comment
Please, Sign In to add comment