Array param does not work

78 views
Skip to first unread message

mar...@handcom.com.br

unread,
Dec 4, 2013, 3:14:41 PM12/4/13
to rubyonra...@googlegroups.com

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 => 'te...@handcom.com.br',
:from_name => 'Pedreco',
:to => [
{:email => 'te...@handcom.com.br'
]
}
})

But if a remove this code: ":to => [{:email => 'te...@handcom.com.br']"

the code work.

Could you help me?

Thanks!!

tamouse pontiki

unread,
Dec 4, 2013, 7:14:12 PM12/4/13
to rubyonra...@googlegroups.com
On Wed, Dec 4, 2013 at 2:14 PM, <mar...@handcom.com.br> wrote:

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 => 'te...@handcom.com.br',
:from_name => 'Pedreco',
:to => [
{:email => 'te...@handcom.com.br'

Right here you forgot to close the hash. 

]
}
})

But if a remove this code: ":to => [{:email => 'te...@handcom.com.br']"

the code work.

Could you help me?

Thanks!!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8adfa5f5-eaa5-4f2a-9a91-51ea20c4715c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

mar...@handcom.com.br

unread,
Dec 4, 2013, 9:20:36 PM12/4/13
to rubyonra...@googlegroups.com
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 => 'te...@handcom.com.br',
:from_name => 'Pedreco',
:to => [{:email => 'te...@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!!!

Matt Jones

unread,
Dec 5, 2013, 8:05:11 AM12/5/13
to rubyonra...@googlegroups.com


On Wednesday, 4 December 2013 21:20:36 UTC-5, mar...@handcom.com.br wrote:
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 => 'te...@handcom.com.br',
:from_name => 'Pedreco',
:to => [{:email => 'te...@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.


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:


--Matt Jones
Reply all
Reply to author
Forward
0 new messages