mailjet / mailjet-gem

[API v3] Mailjet official Ruby GEM

Home Page:https://dev.mailjet.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error 400 while sending

luilver opened this issue · comments

Hello,

I have an API using standalone, Grape or Sinatra controllers (not ActionController). I have properly included gem 'mailjet', bundled and configured my initializers/mailjet.rb as well (with my credentials).

Now when I perform the request to send email, I'm getting this error 400, which is described within docs as "One or more parameters are missing or maybe misspelled (unknown resource or action)."

api_1  | error 400 while sending #<RestClient::Resource:0x000055d85fb51ed0 @url="https://api.mailjet.com/v3/send", @block=nil, @options={:public_operations=>[:post], :read_only=>nil, :perform_api_call=>true, :open_timeout=>nil, :read_timeout=>nil, :user=>"MY_API_KEY", :password=>"MY_API_SECRET", :content_type=>"application/json"}> to https://api.mailjet.com/v3/send with {"Message"=>[{"From"=>{"Email"=>"MY_ACCOUNT_EMAIL", "Name"=>"Test"}, "To"=>[{"Email"=>"ANOTHER_EMAIL", "Name"=>"Another"}], "Subject"=>"Test 1", "TextPart"=>"Hello from me!", "HTMLPart"=>"<h3> Your verification code: 534517</h3>"}]}
api_1  | 
api_1  | "{}"
api_1  | 
api_1  | Please see https://dev.mailjet.com/guides/#status-codes for more informations on error numbers.

I have tried to use config.api_version = "v3.1" without success.

I have no idea what is wrong. I just did perform step by step as you described here.

What is wrong with my parameters?

I found it: My mistake was that :messages is in plural not singular.