marcus-iWDij723SgPQ4tFLR8X5nw@public.gmane.org
2013-Dec-04 20:14 UTC
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-iWDij723SgPQ4tFLR8X5nw@public.gmane.org'', :from_name => ''Pedreco'', :to => [ {:email => ''test2-iWDij723SgPQ4tFLR8X5nw@public.gmane.org'' ] } }) But if a remove this code: ":to => [{:email => ''test2-iWDij723SgPQ4tFLR8X5nw@public.gmane.org'']" 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-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On Wed, Dec 4, 2013 at 2:14 PM, <marcus-iWDij723SgPQ4tFLR8X5nw@public.gmane.org> 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 => ''test1-iWDij723SgPQ4tFLR8X5nw@public.gmane.org'', > :from_name => ''Pedreco'', > :to => [ > {:email => ''test2-iWDij723SgPQ4tFLR8X5nw@public.gmane.org'' >Right here you forgot to close the hash.> > ] > } > }) > > But if a remove this code: ":to => [{:email => ''test2-iWDij723SgPQ4tFLR8X5nw@public.gmane.org'']" > > 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-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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. >-- 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-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHUC_t9iaXf02SZob0D3meQVSDFstoudg_yV2C98x8xPokbesA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
marcus-iWDij723SgPQ4tFLR8X5nw@public.gmane.org
2013-Dec-05 02:20 UTC
Re: Array param does not work
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-iWDij723SgPQ4tFLR8X5nw@public.gmane.org'', :from_name => ''Pedreco'', :to => [{:email => ''test2-iWDij723SgPQ4tFLR8X5nw@public.gmane.org''}] } }) *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!!! On Wednesday, December 4, 2013 10:14:12 PM UTC-2, tamouse wrote:> > > > > On Wed, Dec 4, 2013 at 2:14 PM, <mar...-iWDij723SgPQ4tFLR8X5nw@public.gmane.org <javascript:>>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...-iWDij723SgPQ4tFLR8X5nw@public.gmane.org <javascript:>'', >> :from_name => ''Pedreco'', >> :to => [ >> {:email => ''te...-iWDij723SgPQ4tFLR8X5nw@public.gmane.org <javascript:>'' >> > > Right here you forgot to close the hash. > >> >> ] >> } >> }) >> >> But if a remove this code: ":to => [{:email => ''te...-iWDij723SgPQ4tFLR8X5nw@public.gmane.org<javascript:> >> '']" >> >> 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...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. >> To post to this group, send email to rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:> >> . >> 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. >> > >-- 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-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/907de359-92da-49ea-8b24-eb2dbb14173b%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Wednesday, 4 December 2013 21:20:36 UTC-5, mar...-iWDij723SgPQ4tFLR8X5nw@public.gmane.org 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...-iWDij723SgPQ4tFLR8X5nw@public.gmane.org <javascript:>'', > :from_name => ''Pedreco'', > :to => [{:email => ''te...-iWDij723SgPQ4tFLR8X5nw@public.gmane.org <javascript:>''}] > } > }) > > *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: https://bitbucket.org/mailchimp/mandrill-api-ruby/ --Matt Jones -- 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-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/41b158ff-a3f6-49b8-ae42-f1311287378d%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.