1<script runat="server">
2// CREATE HTML CONTENT BLOCK VIA SSJS
3Platform.Load("Core","1");
4
5try {
6Write("start</br>");
7
8var asset = Platform.Function.CreateObject("Asset");
9
10//Set AssetType (complex property)
11var nameIdReference = Platform.Function.CreateObject("NameIdReference");
12Platform.Function.SetObjectProperty(nameIdReference, "Id", 197); //html block type
13Platform.Function.SetObjectProperty(asset, "AssetType", nameIdReference);
14
15//Set Category (complex property) - aka Folder
16var categoryNameIdReference = Platform.Function.CreateObject("CategoryNameIdReference");
17Platform.Function.SetObjectProperty(categoryNameIdReference, "Id", 43660); //Use the Id value of the desired category (folder)
18Platform.Function.SetObjectProperty(asset, "Category", categoryNameIdReference);
19
20//Set Name, Content, and ContentType (simple text properties)
21Platform.Function.SetObjectProperty(asset, "Name", "SSJS HTML Content Block");
22Platform.Function.SetObjectProperty(asset, "Content", "<div>my new content</div>");
23Platform.Function.SetObjectProperty(asset, "ContentType", "text/html");
24
25var statusAndRequest = [0,0];
26var response = Platform.Function.InvokeCreate(asset, statusAndRequest, null);
27
28Write(response.toString() + "</br>");
29Write(statusAndRequest.toString() + "</br>");
30Write("end</br>");
31
32} catch (err) {
33Write(Stringify(err) + "</br>");
34}
35</script>