title: Ruby posting a HTTP request with arrays using Net::HTTP.post_form
body: <p>I am trying to translate the following PHP script into Ruby in order to communicate with a web API. Unfortunately I don't seem to be able to pass the 'recipients' array in the correct way as it is not interpreted correctly by the API.
  Passing the other parameters works fine though. The problem only appears when passing the recipients array.</p>
  
  <p>How should I format this Array or Hash?</p>
  
  <p>The PHP Script:</p>
  
  <pre><code>&lt;?php
  $params=array (
  'username' =&gt; 'username',
  'password' =&gt; 'password',
  'listId' =&gt; 1,
  'recipients' =&gt;
  array (
  0 =&gt;
  array (
  1 =&gt; 'max@mustermann.de',
  3 =&gt; 'Max',
  ),
  1 =&gt;
  array (
  1 =&gt; 'erika@mustermann.de',
  3 =&gt; 'Erika',
  ),
  ),
  'mode' =&gt; 'update_add',
  'advanced' =&gt;
  array (
  'optoutSync' =&gt; 'global',
  'syncFieldId' =&gt; 1,
  'updateFieldId' =&gt; 3,
  ),
  );
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://login.mailingwork.de/webservice/webservice/json/importrecipients');
  // curl_setopt($ch, CURLOPT_URL, 'http://ruby-doc.org');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
  $result = json_decode(curl_exec($ch),true);
  print "errorcode:".$result['error'];
  print "message:".$result['message'];
  print "result:".print_r($result['result'],true);
  ?&gt;
  </code></pre>
  
  <p>The Ruby Script:</p>
  
  <pre><code>@params = {
      'username' =&gt; 'username',
      'password' =&gt; 'password',
      'listId' =&gt; 1,
      'recipients' =&gt; {
           0 =&gt; { 1 =&gt; 'max@mustermann.de', 3 =&gt; 'Max' }
           #1 =&gt; { 1 =&gt; 'erika@mustermann.de', 3 =&gt; 'Erika2' }
      },
  'mode' =&gt; 'update_add',
  
  'advanced' =&gt; {
      'optoutSync' =&gt; 'global',
      'syncFieldId' =&gt; 1,
      'updateFieldId' =&gt; 3
  }
  }
  
  Net::HTTP.post_form('https://login.mailingwork.de/webservice/webservice/json/importrecipients', @params)
  </code></pre>