I dug as deep as I could but could not find a solution to my problem:
I want to send SOAP requests to ExactTarget API. I am trying to use Savon, but the requests it creates are different from those that worked with ExactTarget's API (I used Java previously) and in the end I get an error when running the Ruby script.
Below is the body of a working request that I am to create in Ruby:
<S:Body>
<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<RetrieveRequest>
<ObjectType>BounceEvent</ObjectType>
<Properties>SendID</Properties>
<Properties>SubscriberKey</Properties>
<Properties>EventDate</Properties>
<Properties>SMTPCode</Properties>
<Properties>BounceCategory</Properties>
<Properties>SMTPReason</Properties>
<Properties>BounceType</Properties>
<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SimpleFilterPart">
<Property>SendID</Property>
<SimpleOperator>equals</SimpleOperator>
<Value>421939</Value>
</Filter>
</RetrieveRequest>
</RetrieveRequestMsg>
</S:Body>
Now here is the code I created in Ruby:
client = Savon.client do
wsdl 'https://webservice.s4.exacttarget.com/etframework.wsdl'
wsse_auth("user", "pass")
end
builder = Builder::XmlMarkup.new
builder.instruct!(:xml, encoding: "UTF-8")
#builder.RetrieveRequestMsg('xmlns'=>'http://exacttarget.com/wsdl/partnerAPI') do
builder.RetrieveRequest do
builder.ObjectType "BounceEvent"
builder.Properties "SendID"
builder.Properties "SubscriberKey"
end
#end
theBody = builder.target!
theBody.slice! '<?xml version="1.0" encoding="UTF-8"?>'
client.call(:retrieve, message: theBody)
..and here is the resulting request body:
<env:Body>
<tns:RetrieveRequestMsg>
<RetrieveRequest>
<ObjectType>BounceEvent</ObjectType>
<Properties>SendID</Properties>
<Properties>SubscriberKey</Properties>
</RetrieveRequest></tns:RetrieveRequestMsg>
</env:Body>
...and here is the resulting error I get:
<soap:Body>
<RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<OverallStatus>Error</OverallStatus>
<RequestID>5ce5cfae-85b4-4e76-b9dd-299e9a9ca871</RequestID>
</RetrieveResponseMsg>
</soap:Body>
Any help is greatly appreciated!