We were requested to create a dynamic subscription/unsubscription center using Cloudpages on Marketing Cloud.
We're trying to implement this using SSJS, but code does not work (throws "Error"):
SSJS
<script runat=server>
Platform.Load("core","1");
var newSubscriber = {
"EmailAddress": "[email protected]",
"SubscriberKey": "[email protected]",
"EmailTypePreference": "Text",
"Attributes":{ "First Name": "test.1", "Last Name": "test.1" },
"Lists": {"Status": "Active", "ID": "1****8", "Action": "Update"}
};
var status = Subscriber.Upsert(newSubscriber);
Write(status);
</script>
We tried both lists and publication lists (being the second one our main goal).
What's wrong with this code? How do I fix it?