Net::HTTP.post_form() doesn’t submit parameters to server
<p>I’m using Rails to post some form data to a web service running php with the Slim framework. My problem is that <code>Net::HTTP.post_form(uri, data)</code> doesn’t submit the data correctly to the server.</p>

<p>My code looks like this:</p>

<p><strong>Rails:</strong></p>

<pre><code>url = URI.parse("http://somewhere.com/login")
username = "my username"
password = "my password"

response = Net::HTTP.post_form(url, username: username, password: password)
</code></pre>

<p><strong>Update:</strong>
Changing the call to 
<code>response = Net::HTTP.post_form(url, { 'username' =&gt; username, 'password' =&gt; password } )</code> as per suggestion from Jon and taglia doesn’t work either.</p>

<p>I even tried to build the request manually like so:</p>

<pre><code>req = Net::HTTP::Post.new uri
req.body = "username=#{username}&amp;password=#{password}"
response = Net::HTTP.start(uri.host, uri.port) {|http| http.request(req)}
</code></pre>

<p>With the same result that the parameters are not correctly sent to my web service.</p>

<p><strong>Slim:</strong></p>

<pre><code>$app-&gt;post('/login', function($request, $response, $args) use ($app, $authenticator) {
  $user_params = $request-&gt;getQueryParams();
  var_dump($user_params);
  echo $authenticator-&gt;login($user_params);
}); // login
</code></pre>

<p>The thing is the Slim side is working. I tested it with Chrome’s Advanced Rest Client App.</p>

<p>Using Rails the <code>var_dump()</code>results in <code>array(0)</code>. So obviously no parameters are submitted to the server. </p>

<p>Anyone got ideas?</p>