I’m having some trouble getting my SOAP envelope to do what I want and
need a little tip. I can’t get the SubscriberCustomField nodes to be
anything but blank:
Here’s what I want it to look like:
<?xml version="1.0" encoding="utf-8"?><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/”>
soap:Body
<Subscriber.AddWithCustomFields
xmlns=“http://api.createsend.com/api/”>
string
string
string
string
comments
Hello World
</Subscriber.AddWithCustomFields>
</soap:Body>
</soap:Envelope>
Here’s what I’m getting:
<?xml version="1.0" encoding="utf-8" ?><env:Envelope xmlns:xsd=“http://www.w3.org/2001/XMLSchema”
xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
env:Body
<n1:Subscriber.AddWithCustomFields
xmlns:n1=“http://api.createsend.com/api/”>
n1:ApiKeystring</n1:ApiKey>
n1:ListIDstring</n1:ListID>
n1:Emailstring</n1:Email>
n1:Namestring</n1:Name>
n1:CustomFields
n1:SubscriberCustomField
</n1:SubscriberCustomField>
n1:SubscriberCustomField
</n1:SubscriberCustomField>
</n1:CustomFields>
</n1:Subscriber.AddWithCustomFields>
</env:Body>
</env:Envelope>
And here’s my code
require ‘soap/wsdlDriver’
require ‘cgi’
@url = “http://#{site_name}.createsend.com/api/api.asmx?wsdl”
@service = SOAP::WSDLDriverFactory.new(@url).create_rpc_driver
str = “”
#custom_fields = “commentshello
world”
#custom_fields = [{:SubscriberCustomField => {:Key => “comments”, :Value
=> “hello world”}}]
#custom_fields = [{:Key => “comments”, :Value => “hello world”}]
#custom_fields = [:comments => “hello world”]
custom_fields = {:SubscriberCustomField => {:Key => “comments”, :Value
=> “hello world”}}
@service.wiredump_dev = str
@service.AddSubscriberWithCustomFields({:ApiKey=>@api_key,
:ListID=>list_id, :Email=>email, :Name=>name, :CustomFields =>
custom_fields})
puts str
The commented custom_fields variables are things I’ve tried with the
same result.
Thanks in advance for the help.