1

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 ?

2
  • Also I would try to replace the header value in the http.post function from ["Delete"] to ["Update"]
    – Duc Le
    Commented Aug 23, 2023 at 9:18
  • Thanks Duc, SF support confirmed the documentation is wrong
    – Johhnytska
    Commented Aug 23, 2023 at 15:24

1 Answer 1

1

I would try to convert it to use with WSProxy library. Here is what I have tried and it worked from my end:

<script runat="server">
Platform.Load("core", "1.1.1");

var listID = "Your List ID";

var prox = new Script.Util.WSProxy();

var sub = {
    SubscriberKey: "[email protected]",
    EmailAddress: "skxxxxx",
    Lists: [{
        ID: listID,
        Action: "delete"
    }]
};

var resp = prox.updateItem("Subscriber", sub);
//Write(Stringify(resp));

</script>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .