Skip to main content
added parsing of access token to the code
Source Link
%%[ 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) ]%% 
%%[ 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) ]%% 
added further links to documentation
Source Link

You can fire the event using a REST-API call to the "POST /interaction/v1/events" endpoint.

An example request looks like this:

{ "ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe" } } 
{ "ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe" } } 

Prerequisites:

Before initiating this request, you need to obtain an access token, that needs to be sent in the header of the request to the /interaction/v1/events endpoint. Requesting this token can be done using the /v1/requestToken endpoint and the following payload:

{ "clientId": "YOUR_CLIENT_ID_FROM_APP_CENTER", "clientSecret": "YOUR_CLIENT_SECRET_FROM_APP_CENTER" } 
{ "clientId": "YOUR_CLIENT_ID_FROM_APP_CENTER", "clientSecret": "YOUR_CLIENT_SECRET_FROM_APP_CENTER" } 

AMPscript example:

%%[ 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:

Further reading:

You can fire the event using a REST-API call to the "POST /interaction/v1/events" endpoint.

An example request looks like this:

{ "ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe" } } 

Prerequisites:

Before initiating this request, you need to obtain an access token, that needs to be sent in the header of the request to the /interaction/v1/events endpoint. Requesting this token can be done using the /v1/requestToken endpoint and the following payload:

{ "clientId": "YOUR_CLIENT_ID_FROM_APP_CENTER", "clientSecret": "YOUR_CLIENT_SECRET_FROM_APP_CENTER" } 

AMPscript example:

%%[ 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) ]%% 

Further reading:

You can fire the event using a REST-API call to the "POST /interaction/v1/events" endpoint.

An example request looks like this:

{ "ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe" } } 

Prerequisites:

Before initiating this request, you need to obtain an access token, that needs to be sent in the header of the request to the /interaction/v1/events endpoint. Requesting this token can be done using the /v1/requestToken endpoint and the following payload:

{ "clientId": "YOUR_CLIENT_ID_FROM_APP_CENTER", "clientSecret": "YOUR_CLIENT_SECRET_FROM_APP_CENTER" } 

AMPscript example:

%%[ 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:

Further reading:

added example code
Source Link

You can fire the event using a REST-API call to the "POST /interaction/v1/events" endpoint.

An example request looks like this:

{ "ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe" } } 

Prerequisites:

Before initiating this request, you need to obtain an access token, that needs to be sent in the header of the request to the /interaction/v1/events endpoint. Requesting this token can be done using the /v1/requestToken endpoint and the following payload:

{ "clientId": "YOUR_CLIENT_ID_FROM_APP_CENTER", "clientSecret": "YOUR_CLIENT_SECRET_FROM_APP_CENTER" } 

AMPscript example:

%%[ 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) ]%% 

Further reading:

You can fire the event using a REST-API call to the "POST /interaction/v1/events" endpoint.

An example request looks like this:

{ "ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe" } } 

Prerequisites:

Before initiating this request, you need to obtain an access token, that needs to be sent in the header of the request to the /interaction/v1/events endpoint. Requesting this token can be done using the /v1/requestToken endpoint and the following payload:

{ "clientId": "YOUR_CLIENT_ID_FROM_APP_CENTER", "clientSecret": "YOUR_CLIENT_SECRET_FROM_APP_CENTER" } 

Further reading:

You can fire the event using a REST-API call to the "POST /interaction/v1/events" endpoint.

An example request looks like this:

{ "ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe" } } 

Prerequisites:

Before initiating this request, you need to obtain an access token, that needs to be sent in the header of the request to the /interaction/v1/events endpoint. Requesting this token can be done using the /v1/requestToken endpoint and the following payload:

{ "clientId": "YOUR_CLIENT_ID_FROM_APP_CENTER", "clientSecret": "YOUR_CLIENT_SECRET_FROM_APP_CENTER" } 

AMPscript example:

%%[ 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) ]%% 

Further reading:

added documentation links
Source Link
Loading
Source Link
Loading