I have a custom Journey Builder activity. What I would like to do, is display a list of fields present in the Entry data source when the user is configuring the activity.
To do this, I have assumed that during the initActivity
trigger from Postmonger I would:
- Request Endpoints
- Request Tokens
- Request Trigger Event Definition
This would then give me the Event Key, Endpoints, and tokens. I assume then that I can use the /interaction/v1/events
REST route https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/postEvent.htm to retrieve a list of data fields in the Event DE.
My code for this:
connection.on('requestedEndpoints',function(endPoints){
console.log("****** ENDPOINTS ******");
connection.on('requestedTriggerEventDefinition',function(eventTrigger){
console.log("****** EVENT ******");
connection.on('requestedTokens',function(tokens){
console.log("************ REQUESTED TOKENS NESTED ****************");
console.log(endPoints);
console.log(eventTrigger);
console.log(tokens);
$.ajax({
url:endPoints.fuelapiRestHost + 'interaction/v1/eventDefinitions/Key:' + eventTrigger.eventDefinitionKey,
method:'GET',
headers:{Authorization:'Bearer ' + tokens.token},
success:function(data,textStatus,jqXHR){
console.log("******************** EVENT REQUEST RESULT ******************");
console.log(data);
}
});
});
connection.trigger('requestTokens');
});
connection.trigger('requestTriggerEventDefinition');
});
Obviously though, because this is done on the front-end, I'm getting CORS policy errors.
But; I don't see any routes documented that would be called prior: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-app-development.meta/mc-app-development/custom-activity-config.htm to allow me to prepare the event fields ahead of time.
Does anyone know how I can accomplish this.