I'm looking to create an Email Send Definition via WSProxy. I am trying to mirror the SOAP Envelope for my proxy script.
I am getting an error when trying to create it; Error Code: 2...
<script runat="server">
Platform.Load("core", "1.1.1");
/* CREATE EMAIL SEND DEFINITION */
var prox = new Script.Util.WSProxy();
var guid = Platform.Function.GUID();
var name = "ESD_" + guid;
var yourSCKey = "SC_Key";
var yourDECustKey = "DE_Key";
var yourExDEID = "ExDE_Key";
var yourEmailCustomerKey = "Email_Key";
var yourEmailName = "EmailName";
var esd = {
"Name": name,
"CustomerKey": guid,
"SendClassification": {
"CustomerKey": yourSCKey
},
"SendDefinitionList": [{
"CustomObjectID": yourDECustKey,
"DataSourceTypeID": "CustomObject",
"List": {
"ListName": "All Subscribers",
"CustomerKey": "XXXXXXXXXXX",
"ListClassification": "PublicationList"
}
},
{
"CustomObjectID": yourExDEID,
"DataSourceTypeID": "CustomObject",
"SendDefinitionListType": "ExclusionList"
}],
"Email": {
"CustomerKey": yourEmailCustomerKey,
"Name": yourEmailName,
"IsApproved": true,
"Subject": name,
},
"IsMultipart": true
}
try{
var res = prox.createItem("EmailSendDefinition", esd);
Write('Response: ' + Stringify(res) + '<br><br>');
var esdCustKey = res.Results[0].Object.CustomerKey
Platform.Response.Write('ESDKey: ' + esdCustKey);
} catch(e) {
Write(Stringify(e));
};
</script>