ASP/SOAP Version of Client.Create

Hiya

Is anyone able to provide advice as to why the following code might not be creating a new client via the API? No error is returned either.

Thanks for your time.

(API Key has been removed for security)

<%
'//-----------------------------INPUT PARAMS---------------------------------------
'START client.Create
strAPIkey = "XXXXXXXXXXXXXXXXXXXXXXX"
strCompanyName = "Big Bank"
strContactName = "Joe Smith"
strEmailAddress = "joe@domain.com"
strCountry = "United States of America"
strTimezone = "(GMT-05:00) Eastern Time (US & Canada)"

'//-------------------------------------------------------------------------------   

postdata = "<?xml version=""1.0"" encoding=""utf-8""?>"
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 & "<Client.Create xmlns=""http://api.createsend.com/api/"">"
postdata = postdata & "<ApiKey>" & strAPIkey & "</ApiKey>"
postdata = postdata & "<CompanyName>" & strCompanyName & "</CompanyName>"
postdata = postdata & "<ContactName>" & strContactName & "</ContactName>"
postdata = postdata & "<EmailAddress>" & strEmailAddress & "</EmailAddress>"
postdata = postdata & "<Country>" & strCountry & "</Country>"
postdata = postdata & "<Timezone>" & strTimezone & "</Timezone>"
postdata = postdata & "</Client.Create>"
postdata = postdata & "</soap:Body>"
postdata = postdata & "</soap:Envelope>"

Dim xmlhttp
set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST","http://api.createsend.com/api/api.asmx" ,false
xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
xmlhttp.setRequestHeader "SOAPAction", """http://api.createsend.com/api/Client.Create"""
xmlhttp.send postdata
Response.Write xmlhttp.responseText
set xmlhttp = nothing
'END client.Create
%>

clarkedesign, 5 years ago

I had some similar problems a while ago where my classic ASP code stopped adding clients.

It turned out that the Country and Time Codes had subtly changed and no one told us.

A good place to start might be to verify these are exactly right.
We just had to remove a couple of brackets in our country code and everything sprang into life again.

jamesd jamesd, 5 years ago

Just a recommendation: if you're writing new code to make API calls, I'd highly recommend using the latest version of our API (v3), which is RESTful and doesn't have a dependency on SOAP. Your code above uses v2 of the API, which will eventually be deprecated.

So if you were using v3 and you wanted to use XML (although, you could also use JSON), your code above would simply need to issue an HTTP POST to http://api.createsend.com/api/v3/clients.xml with the following XML in the body of the request (modified as required by you):

<Client> 
  <CompanyName>My Company</CompanyName>
  <ContactName>John</ContactName>
  <EmailAddress>john@example.com</EmailAddress>
  <Country>Australia</Country>
  <TimeZone>(GMT+10:00) Canberra, Melbourne, Sydney</TimeZone>
</Client>

You can get a list of valid countries and timezones by simply issuing HTTP GET requests to:

http://api.createsend.com/api/v3/countries.xml
http://api.createsend.com/api/v3/timezones.xml

Your v3 API calls will need to include an Authorization header as documented here: http://www.campaignmonitor.com/api/getting-started/#authentication

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