mailgun
mailgun copied to clipboard
Parameter hash sent to RestClient not working
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:[email protected]/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
Did you ever resolve this?
No I found another way to set up routes
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.