%%[ Var @body, @callstatus, @response, @accessToken, @resultOfParsing Set @body = '{"clientId": "xxxxx", "clientSecret": "yyyyyyy"}' HTTPPost2("https://auth.exacttargetapis.com/v1/requestToken", "application/json", @body, True, @callstatus, @response) Set @body = '{"ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe"}}' /* TODO: Insert code to parse the JSON response to extract the value of the accessToken-property and write the parsed value to @resultOfParsing */ Set @accessToken = CONCAT('BEARER ', @resultOfParsing) HTTPPost2("https://auth.exacttargetapis.com/interaction/v1/events", "application/json", @body, True, @callstatus, @response, 'Authorization', @accessToken) ]%% Helpful functions for parsing the response to get the accessToken and get the code working are:
%%[ Var @body, @callstatus, @response, @accessToken, @resultOfParsing Set @body = '{"clientId": "xxxxx", "clientSecret": "yyyyyyy"}' HTTPPost2("https://auth.exacttargetapis.com/v1/requestToken", "application/json", @body, True, @callstatus, @response) Set @body = '{"ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe"}}' Set @regex = '^{"accessToken":"(.*)",.*$' Set @accessToken = REGEXMATCH(@response, @regex, 1) Set @accessToken = CONCAT('Bearer ', @accessToken) HTTPPost2("https://auth.exacttargetapis.com/interaction/v1/events", "application/json", @body, True, @callstatus, @response, 'Authorization', @accessToken) ]%%