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=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
postdata = postdata & "<soap:Body>"
postdata = postdata & "    <Subscriber.Add xmlns=""http://app.csend.com/api/"">"
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")

xmlhttp.open "POST","http://app.csend.com/api/api.asmx" ,false

xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
xmlhttp.setRequestHeader "SOAPAction", """http://app.csend.com/api/Subscriber.Add"""

xmlhttp.send postdata

response = xmlhttp.responseText

Response.Write(response)
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: http://app.csend.com/api/Subscriber.Add. 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?

Thanks!

Brett

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

David,

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
http://www.brettatkin.com

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