Array param does not work

Hello,

in my code, the array param does not work.

reponse = RestClient.post( ‘https://mandrillapp.com/api/1.0/messages/send.json’, {:key => “XXXXXXXXXXXXXXXXX”, :message => { :html => ’

testeeeee

', :text => ‘Example text content’, :subject => ‘example subject’, :from_email => ‘test1@handcom.com.br’, :from_name => ‘Pedreco’, :to => [ {:email => ‘test2@handcom.com.br’ ] } }) But if a remove this code: “:to => [{:email => ‘test2@handcom.com.br’]”

the code work.

Could you help me?

Thanks!!

Hello,

in my code, the array param does not work.

reponse = RestClient.post( 'https://mandrillapp.com/api/1.0/messages/send.json’, {:key => "XXXXXXXXXXXXXXXXX", :message => { :html => '

testeeeee ', :text => 'Example text content', :subject => 'example subject', :from_email => 'test1@handcom.com.br', :from_name => 'Pedreco', :to => [ {:email => 'test2@handcom.com.br'

Right here you forgot to close the hash.

Hi tamouse,

thank you your replay.

I close the hash but the erro continues, see:

My code:

reponse = RestClient.post( ‘https://mandrillapp.com/api/1.0/messages/send.json’, {:key => “XXXXXXXXXXXXXXXXX”, :message => { :html => ‘testeeeee’,

:text => ‘Example text content’,

:subject => ‘example subject’, :from_email => ‘test1@handcom.com.br’, :from_name => ‘Pedreco’, :to => [{:email => ‘test2@handcom.com.br’}] } })

the error:

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

I’m using the Mandrill API.

Thank’s!!!

RestClient sends requests as application/x-www-form-urlencoded by default, so your data is getting flattened out. Try adding { :content_type => :json } as the last argument to your call.

You may also want to evaluate what you need to do that isn’t already covered by the vendor-supported Mandrill API gem:

https://bitbucket.org/mailchimp/mandrill-api-ruby/

–Matt Jones