Mandrill:请输入一个数组

时间:2013-12-29 13:47:18

标签: mandrill

我无法理解为什么我会得到一个无效数组!

response = Unirest.post "#{@@endpoint}/messages/send.json", 
                        headers:{ "Accept" => "application/json" }, 
                        parameters:{ 
                            :key => @@apikey, 
                            :message => {
                                :text => "example text",
                                :subject => "bla bla",
                                :from_email => "info@site.com",
                                :from_name => "site.com",
                                to: [
                                        {
                                            :email => "myemail@gmail.com",
                                            :name  => "myname",
                                            :type  => "to"
                                        }
                                ]
                            }
                        }

我收到此错误

{"status":"error","code":-2,"name":"ValidationError","message":"Validation error: {\"message\":{\"to\":[\"Please enter an array\"]}}"}

1 个答案:

答案 0 :(得分:4)

to数组不应该

[to]=> 
   array( 
       [0]=>array(
                [email] => "myemail@gmail.com",
                [name]  => "myname",
                [type]  => "to"
                )
        )