Skip to content

Parameter hash sent to RestClient not working #34

Description

@erithmetic

When I perform a Mailgun().routes.create or Mailgun().routes.update command, I get the following error:

{                                           
  "message": "'action' parameter is missing"
}                                           

I debugged the problem and found that at https://github.com/HashNuke/mailgun/blob/master/lib/mailgun/base.rb#L71 RestClient is not recognizing the parameters hash passed to it and not posting parameters to Mailgun, even though it has data.

Here's my test code:

  def self.create(pattern)                                                     
    mailgun.routes.create "Catch-all route for #{ENV['MAILGUN_ROUTE_DOMAIN']}",
      DEFAULT_PRIORITY,                                                        
      [:match_recipient, pattern],                                             
      [[:forward, endpoint_url], [:stop]]                                      
  end                                                                          

  # ...

  describe '.create' do                                         
    let(:pattern) { '.*@.*.test.com' }                      

    it 'creates a route' do                                     
      VCR.use_cassette :email_route_create do                   
        EmailRoute.create pattern                               

        expect(EmailRoute.existing_route(pattern)).to be_present
      end                                                       
    end                                                         

  end                                                           

Here's a dump of my VCR cassette during a create:

---                                                                                
http_interactions:                                                                 
- request:                                                                         
    method: post                                                                   
    uri: https://api:key-secret@api.mailgun.net/v2/routes
    body:                                                                          
      encoding: UTF-8                                                              
      string: ''                                                                   
    headers:                                                                       
      Accept:                                                                      
      - "*/*; q=0.5, application/xml"                                              
      Accept-Encoding:                                                             
      - gzip, deflate                                                              
      User-Agent:                                                                  
      - Ruby                                                                       
  response:                                                                        
    status:                                                                        
      code: 400                                                                    
      message: BAD REQUEST                                                         
    headers:                                                                       
      Server:                                                                      
      - nginx/1.4.7                                                                
      Date:                                                                        
      - Wed, 27 Aug 2014 00:50:55 GMT                                              
      Content-Type:                                                                
      - application/json                                                           
      Content-Length:                                                              
      - '48'                                                                       
      Connection:                                                                  
      - keep-alive                                                                 
    body:                                                                          
      encoding: UTF-8                                                              
      string: |-                                                                   
        {                                                                          
          "message": "'action' parameter is missing"                               
        }                                                                          
    http_version:                                                                  
  recorded_at: Wed, 27 Aug 2014 00:53:28 GMT                                       
recorded_with: VCR 2.9.2                                                           

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions