I am using the below SSJS to clear out a data extension. It works well in the Parent BU but when I run it in a Child Business Unit it fails
<script language="javascript" runat="server">
Platform.Load("Core","1");
var payload = '';
var username = 'xxx';
var password = 'yyy';
var endpoint = "https://webservice.s6.exacttarget.com/Service.asmx";
var custkey = 'Training Sergio'
var result;
payload += '<?xml version="1.0" encoding="utf-8"?>';
payload += '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
payload += ' <soap:Header>';
payload += ' <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soap:mustUnderstand="1">';
payload += ' <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-1">';
payload += ' <wsse:Username>' + username + '</wsse:Username>';
payload += ' <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' + password + '</wsse:Password>';
payload += ' </wsse:UsernameToken>';
payload += ' </wsse:Security>';
payload += ' </soap:Header>';
payload += ' <soap:Body>';
payload += ' <PerformRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI" xmlns:ns2="urn:fault.partner.exacttarget.com">';
payload += ' <Action>ClearData</Action>';
payload += ' <Definitions>';
payload += ' <Definition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="DataExtension">';
payload += ' <CustomerKey>'+custkey+'</CustomerKey>';
payload += ' </Definition>';
payload += ' </Definitions>';
payload += ' </PerformRequestMsg>';
payload += ' </soap:Body>';
payload += '</soap:Envelope>';
try {
result = HTTP.Post(endpoint,"text/xml",payload,["SOAPAction"],["Perform"]);
} catch(e) {
result = {StatusCode:500,Response:Stringify(e)};
}
if (result.StatusCode != 200) {
//Bad response
Write(Stringify(result));
} else {
//Good response
Write(Stringify(result));
}
</script>
This is the error that I am getting
{"StatusCode":200,"Response":["PerformResponseurn:uuid:6ac6d18f-dfc1-4239-93f4-0d6ecf4d8284urn:uuid:1d0a8836-e3e3-41ce-bb4f-4a9d616df0d8http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous2018-12-14T20:39:28Z2018-12-14T20:44:28ZErrorException occured during perform ClearData operation on DataExtension: 00000000-0000-0000-0000-000000000000, CustomerKey: ErrorID: 429699442Training SergioError5cad672d-9eb5-4485-8c68-25c95f491e71"]}
Also tried the the CLientID but that doesn't help either
<Client>
<ID>ddd1257</ID>
</Client>