I found out on this forum there is an option with Marketing Cloud API to retrieve all the Data Extensions associated with Journeys.
When using Postman, the request below works perfectly
GET /interaction/v1/eventDefinitions/
Host: xxx.rest.marketingcloudapis.com
Authorization: Bearer xxx
It returns an object that I can query without issues.
However, when trying to run the same script as part of a SSJS Activity in Automation Studio, it just fails.
<script runat="server">
Platform.Load("core","1");
var authEndpoint = 'https://xxx.auth.marketingcloudapis.com';
var payload = {
clientId: "xxx",
clientSecret: "xxx"
};
var authurl = authEndpoint + '/v1/requestToken';
var contentType = 'application/json';
var accessTokenRequest = HTTP.Post(authurl, contentType, Stringify(payload));
if(accessTokenRequest.StatusCode == 200) {
var tokenResponse = Platform.Function.ParseJSON(accessTokenRequest.Response[0]);
var accessToken = tokenResponse.accessToken;
var auth = "Bearer " + accessToken;
}
}
/* Get the Journeys details */
try {
var deEndpoint = "https://xxx.rest.marketingcloudapis.com/interaction/v1/eventDefinitions/";
var HeaderNames = ["Authorization"];
var HeaderValues = [Auth]
var deRequest = HTTP.Get(deEndpoint, HeaderNames, HeaderValues);
var requestResponse = Platform.Function.ParseJSON(deRequest.Response[0]);
Write("Object: "+ requestResponse);
} catch (err) {
Write(Stringify(err));
}
</script>
After executing the Activity, it returns Object: null
I couldn't find any information in the documentation about this API though:
GET /interaction/v1/eventDefinitions/, only from comments on this forum.
How to get Data Extension ID using Journey ID
Is there an alternative way to run the same request? Thank you
Best Answer
this code will return all the journeys. I will share the code to fetch DE names later. Please refer to the documentation link: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/getInteractionCollection.html