I've managed to get an ImportDefinition created with the destination object being a list in postman, but I'm struggling a bit with wsproxy, I'm getting a 500 server error. My contentJson is read ok, and my listID is returned ok.
<script runat="server">
Platform.Load("core", "1.1.1");
var api = new Script.Util.WSProxy();
try {
var soapObjName = "ImportDefinition";
var filter =
{
Property: "ListName",
SimpleOperator: "equals",
Value: "All Subscribers"
};
var req = api.retrieve("List", ["ID"], filter);
//set the listID variable with the results
var listID = req.Results[0].ID;
var contentJSON =
[ {
CustomerKey: "wsProxyImportDef",
Name: "wsProxyImportDefName",
Description: "wsProxyImportDefDesc",
AllowErrors: true,
DestinationObject: [{
DestinationType: "List",
ID: listID
}],
FieldMappingType: "InferFromColumnHeadings",
FieldSpec: "Import2M2L.csv",
FileType: "CSV",
Notification: [{
"ResponseType": "email",
"ResponseAddress": "developer@xyz"
}],
UpdateType: "Add and Update"
}
];
var createImportDefinition = createGeneric(soapObjName, contentJSON, '')
Write(Stringify(createImportDefinition))
function createGeneric(soapObjName, contentJSON, mid) {
try {
if (mid) {
api.resetClientIds();
//reset previous settings
//Set ClientID
api.setClientId({
ID: mid
});
}
var batch = isArray(contentJSON);
Write(Stringify(batch))
if (batch) {
var res = api.createBatch(soapObjName, contentJSON);
} else {
var res = api.createItem(soapObjName, contentJSON);
}
function isArray(arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
return res;
} catch (err) {
Write(Stringify(err))
}
}
</script>
Thanks to Gortonington and Jason Henshaw for the ws proxy create framework
System.ArgumentException: Object of type 'System.Collections.ArrayList' cannot be converted to type 'ExactTarget.Integration.WSDL.APIObject'. - from mscorlib
false{"message":"Item properties are not valid.","description":"ExactTarget.OMM.InvalidFunctionParameterException: Item properties are not valid.\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from Jint\r\n\r\n"}nul
but I don't think the issue is with the description field