Write quaratine to Message Center Execution instance
I need to write to the address schema (quarantines) on the Message Center execution instance due to spam trap hits. I will in practice write quarantines present on the marketing instance to the message center instance since there is no sync out of the box.
I've tried to run the below code in a workflow but get error: INT-150012 The HTTP query returned a 'Forbidden' type error (403)
I use the same connection information to query for current quarantines in message center in another workflow.
How can I make this work to write to nms:address in execution instance?
Is it just a matter of getting credentials to a login with admin (write) permission on the execution server.
NOTE: Code and error example updated after adding try catch and changing from NlElement to string as input param.
//--ACCOUNT AND LOGON DATA
var extAccount = instance.vars.extAccountId;
var rtCell = NL.ExecutionInstance.getExtAccount(extAccount, NL.ExecutionInstance.MESSAGECENTER_TYPE);
if( !NL.XTK.parseBoolean(rtCell.@active) ) { logError("account disabled");}
vars.login = String(rtCell.@account);
vars.password = String(rtCell.@password);
vars.url = String(rtCell.@server);
//-----INIT CONNECTION----
document.cnx = new HttpSoapConnection(vars.url + '/nl/jsp/soaprouter.jsp', 'utf-8', 0)
document.soapSrv = new SoapService(cnx, 'urn:xtk:session')
document.soapSrv.addMethod('Write', 'xtk:session#Write',['object','string'],[])
var tokens = NL.ExecutionInstance.logonRemote(vars.url, vars.login, vars.password);
document.cnx.addTokens(tokens["sessionToken"], tokens["securityToken"]);
//WRITE ADDRESS
var newAddress = "<address type='0' status='4' address='peter@example.com' quarantineReason='2' xtkschema='nms:address' _operation='insertOrUpdate'/>";
//xtk.session.Write(newAddress); //Test if object can be saved in marketing instance
try{
document.soapSrv.Write(newAddress);
}
catch( e )
{
if( e.soapFault ) logInfo("A SOAP Fault occured : " + e.soapFault.toXMLString());
else logInfo("An error occured : " + e);
}
//--------END------------
document.soapSrv.dispose();
document.cnx.dispose();