Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delivery save returns invalid request error (107) from Bronto #15

Closed
waterjump opened this issue Jun 8, 2015 · 1 comment
Closed

Delivery save returns invalid request error (107) from Bronto #15

waterjump opened this issue Jun 8, 2015 · 1 comment

Comments

@waterjump
Copy link

Using this gem, and testing a very basic example, the delivery.save command errors returns an error from Bronto: 107: There was an error in your soap request. Please examine the request and try again.

Other calls to the API in this example, such as contact.save and message.save were successful. The only slight difference between my test and the example in the readme, is that I pass in an object of type Bronto::Contact instead of a Bronto::List object to deliver.add_recipient. I've inspected this method and it seems it can handle a contact instead of a list.

My full test is below, followed by the actual http request dumped from Savon (operation.rb:~113). Actual values and IDs have been redacted.

>> Bronto::Base.api_key = '11111111-1111-1111-1111-111111111111'

>> contact = Bronto::Contact.new(email:'test-recipient-email@example.com')
=> #<Bronto::Contact:0x007fb29e32a188 @fields={}, @api_key="11111111-1111-1111-1111-111111111111", @errors=#<Bronto::Errors:0x007fb29e32a110 @messages={}>, @email="test-recipient-email@example.com">
>> contact.save
=> [#<Bronto::Contact:0x007fb29e32a188 @fields={}, @api_key="11111111-1111-1111-1111-111111111111", @errors=#<Bronto::Errors:0x007fb29e32a110 @messages={}>, @email="test-recipient-email@example.com", @id="22222222-2222-2222-2222-222222222222">]

>> message = Bronto::Message.new(name: "Test Message4")
>> message.add_content("html", "HTML Subject", "HTML Content")
>> message.add_content("text", "Text Subject", "Text Content")
>> message.save
=> #<Bronto::Message:0x007fb292f69950 @api_key="11111111-1111-1111-1111-111111111111", @errors=#<Bronto::Errors:0x007fb292f69928 @messages={}>, @name="Test Message4", @content={"html"=>#<Bronto::Message::Content:0x007fb292f62628 @type="html", @subject="HTML Subject", @content="HTML Content">, "text"=>#<Bronto::Message::Content:0x007fb292f5b2d8 @type="text", @subject="Text Subject", @content="Text Content">}, @id="33333333-3333-3333-3333-333333333333">

>> delivery = Bronto::Delivery.new(start: Time.now, type: "normal", from_name: "Test", from_email: "test@example.com")
=> #<Bronto::Delivery:0x007fb293930fd8 @api_key="11111111-1111-1111-1111-111111111111", @errors=#<Bronto::Errors:0x007fb293930fb0 @messages={}>, @start=2015-06-08 14:43:05 -0400, @type="normal", @from_name="Test", @from_email="test@example.com", @recipients=[]>
>> delivery.message_id = message.id
=> "33333333-3333-3333-3333-333333333333"
>> delivery.add_recipient(contact)
=> [{:id=>"22222222-2222-2222-2222-222222222222", :type=>"contact"}]

>> delivery.inspect
=> "#<Bronto::Delivery:0x007fb293930fd8 @api_key=\"11111111-1111-1111-1111-111111111111\", @errors=#<Bronto::Errors:0x007fb293930fb0 @messages={}>, @start=2015-06-08 14:43:05 -0400, @type=\"normal\", @from_name=\"Test\", @from_email=\"test@example.com\", @recipients=[{:id=>\"22222222-2222-2222-2222-222222222222\", :type=>\"contact\"}], @message_id=\"33333333-3333-3333-3333-333333333333\">"

>> delivery.save
Savon::SOAPFault: (soap:Client) 107: There was an error in your soap request. Please examine the request and try again.
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/response.rb:85:in `raise_soap_and_http_errors!'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/response.rb:14:in `initialize'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:72:in `new'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:72:in `create_response'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:58:in `call'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/client.rb:36:in `call'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bronto-0.3.1/lib/bronto/base.rb:38:in `request'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bronto-0.3.1/lib/bronto/base.rb:101:in `create'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bronto-0.3.1/lib/bronto/base.rb:191:in `create'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bronto-0.3.1/lib/bronto/base.rb:186:in `save'
  from (irb):14
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/console.rb:110:in `start'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/console.rb:9:in `start'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:68:in `console'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
  from /Users/waterjump/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'>> 

#<HTTPI::Request:0x007fb29e485118 
  @follow_redirect=false, 
  @url=#<URI::HTTPS https://api.bronto.com/v4>, 
  @headers={"SOAPAction"=>"\"addDeliveries\"", "Content-Type"=>"text/xml;charset=UTF-8", "Content-Length"=>"701"}, 
  @body=
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
    <env:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:tns=\"http://api.bronto.com/v4\" xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">
      <env:Header>
        <tns:sessionHeader><sessionId>44444444-4444-4444-4444-444444444444</sessionId></tns:sessionHeader>
      </env:Header>
      <env:Body>
        <tns:addDeliveries>
          <deliveries>
            <start>14:43:05</start>
            <messageId>33333333-3333-3333-3333-333333333333</messageId>
            <fromEmail>test@example.com</fromEmail>
            <fromName>Test</fromName>
            <recipients>
              <id>22222222-2222-2222-2222-222222222222</id>
              <type>contact</type>
            </recipients>
          </deliveries>
        </tns:addDeliveries>
      </env:Body>
    </env:Envelope>", 
  @read_timeout=600
>
@martingordon
Copy link
Owner

I believe the issue is with start. The Bronto API requires it in a specific format. I've pushed a new version of the gem to be more flexible with it, so your code should not have to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants