forked from HowToSFMC/scriptmas2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
js_apiShell.js
42 lines (31 loc) · 875 Bytes
/
js_apiShell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<script runat='server'>
Platform.Load("core", "1.1.1");
var accessToken = getAccessToken();//get accessToken
var getJourneyConfig = {
endpoint: "interaction/v1/interactions/"
method: "GET"
}
function scriptUtil(config, accessToken) {
var method = config.method;
var url = "restBase" + config.endpoint;
try {
var req = new Script.Util.HttpRequest(url);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json"
req.method = method;
req.setHeader("Authorization", "Bearer " + accessToken);
if (config.payload) {
req.postData = Stringify(config.payload);
}
var resp = req.send();
var resultStr = String(resp.content);
var resultJSON = Platform.Function.ParseJSON(String(resp.content));
return resultJSON;
} catch (e) {
Write("API (e)" + Stringify(e));
return
};
}
</script>