Subscriber .Add problem

I have the following code working on another site...except for I have changed all references from "campaignmonitor" to "c/send"


' add subscriber to Campaign Monitor

If Request.Form("newsletter_subscribe") = "Yes" Then

dim apikey, listid, name, email, postdata, response

apikey = "xxxxxx" 'Your api key
listid = xxxxxx    'your list id

name = Request.Form("full_name")
email = Request.Form("email_address")

postdata = ""
postdata = postdata & "<soap:Envelope xmlns:xsi="""" xmlns:xsd="""" xmlns:soap="""">"
postdata = postdata & "<soap:Body>"
postdata = postdata & "    <Subscriber.Add xmlns="""">"
postdata = postdata & "        <ApiKey>" & apikey & "</ApiKey>"
postdata = postdata & "        <ListID>" & listid & "</ListID>"
postdata = postdata & "        <Email>" & email & "</Email>"
postdata = postdata & "        <Name>" & name & "</Name>"
postdata = postdata & "    </Subscriber.Add>"
postdata = postdata & "</soap:Body>"
postdata = postdata & "</soap:Envelope>"

Dim xmlhttp
Set xmlhttp=Server.CreateObject("Microsoft.XMLHTTP") "POST","" ,false

xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
xmlhttp.setRequestHeader "SOAPAction", """"""

xmlhttp.send postdata

response = xmlhttp.responseText

End If

I'm getting the following error message.

soap:ClientSystem.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

What is going wrong?



davidh, 7 years ago

Hi Brett,

In your code I think all the references to app.createsend should be api.createsend instead. I am not 100% sure that is the problem but there is a good chance. If you try that and it still doesn't work let us know either here or by emailing support.

baatkin65, 7 years ago


I changed the app.createsend to api.createsend and it worked fine once I changed the API key to my account API and not the client API.

I don't understand that.  Why do I have to use my account API Key and not the client API Key?

Brett Atkin

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