title: How to send HTTParty POST call with body values as form-data
body: <p>I have a RoR application from where I need to call a 3rd party API with several different calls. GET requests work fine with both Postman and HTTParty, but I can't get POST to work with latter. In Postman, I have a default request with <em>basic auth</em>, <em>headers</em> and a half dozen parameters in the <em>body</em> with the default form-data option.</p>
  
  <p>The Postman request works fine, but I've been having hard time to replicate the request to HTTParty, leading to the API responding with error as parameters are missing.</p>
  
  <p>Here's some of the code I've been working with to no avail:</p>
  
  <pre class="lang-rb prettyprint-override"><code>options = { headers: {"Accept"=&gt;"application/json", "Content-Type"=&gt;"application/json"}, 
  :debug_output =&gt; $stdout, body: { "param1" =&gt; 1, "param2" =&gt; 5, 
  "param3" =&gt; 'foo', "param4" =&gt; 'bar', "param5" =&gt; 'test' }
  .to_json, 
  basic_auth: {:username=&gt;'censored', :password=&gt;'censored'} }
  
  response = HTTParty.post("#{Settings.api_url}", options)
  
  opening connection to ...
  opened
  starting SSL for ...
  SSL established
  &lt;- "POST ... HTTP/1.1\r\nAccept: application/json\r\n
  Content-Type: application/json\r\nAuthorization: Basic censored\r\nConnection: close\r\n
  Host: www.censored.com\r\n
  Content-Length: 113\r\n\r\n"
  &lt;- "{\"param1\":1,\"param2\":5,\"param3\":\"foo\",\"param4\":\"bar\",\"param5\":\"test\"}"
  -&gt; "HTTP/1.1 200 OK\r\n"
  -&gt; "Server: Apache\r\n"
  -&gt; "Set-Cookie: PHPSESSID=...; path=/\r\n"
  -&gt; "Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
  -&gt; "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
  -&gt; "Pragma: no-cache\r\n"
  -&gt; "Content-Length: 61\r\n"
  -&gt; "Connection: close\r\n"
  -&gt; "Content-Type: application/json\r\n"
  -&gt; "\r\n"
  reading 61 bytes...
  </code></pre>
  
  <p>and then comes the error response. I tried with various combinations regarding body, also trying to set Accept and Content-Type headers to multipart/formdata but didn't get it working. How could I replicate the Postman request?</p>