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

Parameter hash sent to RestClient not working #34

Open
erithmetic opened this issue Aug 27, 2014 · 3 comments
Open

Parameter hash sent to RestClient not working #34

erithmetic opened this issue Aug 27, 2014 · 3 comments

Comments

@erithmetic
Copy link

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                                                           
@toxaq
Copy link

toxaq commented Nov 14, 2014

Did you ever resolve this?

@erithmetic
Copy link
Author

No I found another way to set up routes

@toxaq
Copy link

toxaq commented Nov 15, 2014

Right, so it's not the code, it's the Multimap hash not working with Restclient. Not sure if it's version specific or not.

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