Skip to content

Instantly share code, notes, and snippets.

@MamaiRachid
Last active December 3, 2020 05:09
Show Gist options
  • Save MamaiRachid/849935c6cec50d6a9aa9578404ecfa23 to your computer and use it in GitHub Desktop.
Save MamaiRachid/849935c6cec50d6a9aa9578404ecfa23 to your computer and use it in GitHub Desktop.
<script runat="server">
Platform.Load("Core","1.1.1");
/* The number of autoamtions we want to pull */
var automationsCount = 25;
url = tenantURL + ".rest.marketingcloudapis.com/legacy/v1/beta/automations/automation/definition/?$top="+ automationsCount +"&$skip=0&$sort=lastRunTime%20desc";
var headerNames = ["Authorization"];
var headerValues = ["Bearer " + accessToken];
var automations, automationContent, automationDescription;
try {
automations = HTTP.Get(url, headerNames, headerValues);
automationContent = Platform.Function.ParseJSON(Platform.Function.ParseJSON(Stringify(automations)).Content);
// loop through all results
if(automationContent.entry.length >= 1) {
for (i = 0; i < automationContent.entry.length; i++) {
automationDescription = automationContent.entry[i].description;
Write(automationDescription + "</br>");
/* Do other stuff */
}
}
} catch (e) {
e = Stringify(e).replace(/[\n\r]/g, '')
Write(e);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment