ASP/SOAP Version of Client.Create


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
strCompanyName = "Big Bank"
strContactName = "Joe Smith"
strEmailAddress = ""
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="""" xmlns:xsd="""" xmlns:soap="""">"
postdata = postdata & "<soap:Body>"
postdata = postdata & "<Client.Create xmlns="""">"
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") "POST","" ,false
xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
xmlhttp.setRequestHeader "SOAPAction", """"""
xmlhttp.send postdata
Response.Write xmlhttp.responseText
set xmlhttp = nothing
'END client.Create

clarkedesign, 6 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, 6 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 with the following XML in the body of the request (modified as required by you):

  <CompanyName>My Company</CompanyName>
  <TimeZone>(GMT+10:00) Canberra, Melbourne, Sydney</TimeZone>

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

Your v3 API calls will need to include an Authorization header as documented here:

See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free