Given a suppression list, I am able to delete a subscriber from the list using SoapUI, I just pass the access token in the xml and I retrieve message 200 and the contact is deleted. However, when translating this to SSJS I get (400) Bad Request. I tried different options for the http.post function but no luck. Here's the code:
<script runat="server">
Platform.Load("core", "1");
// Set your access token
var accessToken = "eyJhbGciO..";
// Set up SOAP API endpoint
var endpoint = "https://custom.soap.marketingcloudapis.com/Service.asmx";
// Create SOAP request envelope
var payload = '';
payload += '<?xml version="1.0" encoding="utf-8"?>';
payload += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
payload += ' <soapenv:Header>';
payload += ' <fueloauth>' + accessToken + '</fueloauth>';
payload += ' </soapenv:Header>';
payload += ' <soapenv:Body>'
payload += ' <Objects xsi:type="Subscriber">'
payload += ' <EmailAddress>[email protected]</EmailAddress>'
payload += ' <SubscriberKey>skxxxxx</SubscriberKey>'
payload += ' <Lists>'
payload += ' <PartnerKey xsi:nil="true"/>'
payload += ' <ID>111111</ID>'
payload += ' <Action>delete</Action>'
payload += ' </Lists>'
payload += ' </Objects>'
payload += ' </soap:Body>'
payload += '</soapenv:Envelope>';
// Send the SOAP request and get response
try {
var result = HTTP.Post(endpoint, "text/xml", payload, ["SOAPAction"], ["Delete"]);
// Process the result as needed
Write("Response: " + result.Content);
} catch (e) {
Write("Error: " + Stringify(e));
}
</script>
Any idea what can be wrong here ?
["Delete"]
to["Update"]