API SOAP Security

Hi
I'm using the API from within Flash to add new subscribers to my list with custom fields. This requires the use of SOAP. It works great when I use http://api.createsend.com/api/api.asmx, but fails when I use the secure https://api.createsend.com/api/api.asmx. Please look at my code below and let me know where I'm going wrong:

    var soapCall = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"
    soapCall += "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" xmlns:tm=\"http://microsoft.com/wsdl/mime/textMatching/\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:mime=\"http://schemas.xmlsoap.org/wsdl/mime/\" xmlns:tns=\"http://api.createsend.com/api/\" xmlns:s=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://schemas.xmlsoap.org/wsdl/soap12/\" xmlns:http=\"http://schemas.xmlsoap.org/wsdl/http/\" xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >"
    soapCall += "<SOAP-ENV:Body>"
    soapCall += "<tns:Subscriber.AddAndResubscribeWithCustomFields xmlns:tns=\"http://api.createsend.com/api/\">"
    soapCall += "<tns:ApiKey>"+myApiId+"</tns:ApiKey>"
    soapCall += "<tns:ListID>"+myListId+"</tns:ListID>"
    soapCall += "<tns:Email>"+email+"</tns:Email>"
    soapCall += "<tns:Name>"+name+"</tns:Name>"
    soapCall += "<tns:CustomFields>"
   
    soapCall += "<tns:SubscriberCustomField>"
    soapCall += "<tns:Key>"+customFieldName1+"</tns:Key>"
    soapCall += "<tns:Value>"+customFieldValue1+"</tns:Value>"
    soapCall += "</tns:SubscriberCustomField>"
   
    soapCall += "<tns:SubscriberCustomField>"
    soapCall += "<tns:Key>"+customFieldName2+"</tns:Key>"
    soapCall += "<tns:Value>"+customFieldValue2+"</tns:Value>"
    soapCall += "</tns:SubscriberCustomField>"
   
    soapCall += "<tns:SubscriberCustomField>"
    soapCall += "<tns:Key>"+customFieldName3+"</tns:Key>"
    soapCall += "<tns:Value>"+customFieldValue3+"</tns:Value>"
    soapCall += "</tns:SubscriberCustomField>"   
   
    soapCall += "<tns:SubscriberCustomField>"
    soapCall += "<tns:Key>"+customFieldName4+"</tns:Key>"
    soapCall += "<tns:Value>"+customFieldValue4+"</tns:Value>"
    soapCall += "</tns:SubscriberCustomField>"
   
    soapCall += "<tns:SubscriberCustomField>"
    soapCall += "<tns:Key>"+customFieldName5+"</tns:Key>"
    soapCall += "<tns:Value>"+customFieldValue5+"</tns:Value>"
    soapCall += "</tns:SubscriberCustomField>"
   
    soapCall += "<tns:SubscriberCustomField>"
    soapCall += "<tns:Key>"+customFieldName6+"</tns:Key>"
    soapCall += "<tns:Value>"+customFieldValue6+"</tns:Value>"
    soapCall += "</tns:SubscriberCustomField>"
   
    soapCall += "<tns:SubscriberCustomField>"
    soapCall += "<tns:Key>"+customFieldName7+"</tns:Key>"
    soapCall += "<tns:Value>"+customFieldValue7+"</tns:Value>"
    soapCall += "</tns:SubscriberCustomField>"

    soapCall += "</tns:CustomFields>"
    soapCall += "</tns:Subscriber.AddAndResubscribeWithCustomFields>"
    soapCall += "</SOAP-ENV:Body>"
    soapCall += "</SOAP-ENV:Envelope>";

    myXML = new XML(soapCall);
    myXML.addRequestHeader("Content-Type","text/xml; charset=utf-8");
    myXML.addRequestHeader("SOAPAction","http://api.createsend.com/api/Subscriber.AddAndResubscribeWithCustomFields");
    myXML.sendAndLoad("https://api.createsend.com/api/api.asmx",feedback);

Phil Phil, 6 years ago

Hi hellodaylight,

Your code might not be the problem here. I did a bit of research and our api's crossdomain policy might not have been allowing submissions to the secure endpoint from a flash component on a normal http source.

I've modified the policy, but i'll need you to test for us. If you're still having problems, would you be able to drop us a support request with a bit more detail (such as what happens when you say it "fails")?

Thanks,
Phil

hellodaylight, 6 years ago

Hi Phil. Thanks for your quick response. I just tested again, but still not working. From code above, when I change the https to the regular http calls, it works fine and returns success or failure with messages. The https calls return nothing, and does not add the user.

hellodaylight, 6 years ago

Oh, and I put in a support request, so I'll post here when fixed.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098