title: How to make a HTTP POST request from Ruby
body: <p>I've never done POSTs in Ruby before and I'm missing something simple.</p>
  
  <p>I am trying to make this request:</p>
  
  <pre><code>curl -s -X POST "http://example.com:8280/purest/chatbot/actions/message" --data "message=hello there&amp;rooms=myroom"
  </code></pre>
  
  <p>I have: </p>
  
  <pre><code>    url = "http://example.com:8280"
      uri = URI.parse(url)
  
      http = Net::HTTP.new(uri.host, uri.port)
      http.set_debug_output($stdout)
  
      request = Net::HTTP::Post.new("/purest/chatbot/actions/message")
      request.body = "message=hey from me in ruby&amp;rooms=myroom"
  
      response = http.request(request)
  </code></pre>
  
  <p>This is the output:</p>
  
  <pre><code>&lt;- "POST /purest/chatbot/actions/message HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: example.com:8280\r\nContent-Length: 60\r\n\r\n"
  &lt;- "message=hey from except now from ruby&amp;rooms=myroom"
  -&gt; "HTTP/1.1 400 Bad Request\r\n"
  -&gt; "Server: nginx\r\n"
  -&gt; "Date: Thu, 27 Apr 2017 18:33:33 GMT\r\n"
  -&gt; "Content-Type: application/json; charset=utf-8\r\n"
  -&gt; "Transfer-Encoding: chunked\r\n"
  -&gt; "Connection: close\r\n"
  -&gt; "Content-Language: en-US\r\n"
  -&gt; "Session-Id: \r\n"
  -&gt; "Cache-Control: no-cache\r\n"
  -&gt; "X-Moawsl-Info: php_pid=52478;php_tte_ms=14.93;php_hit=250;php_cpu_ms=15.02;maxrss=223016;customer_id=;session_order_id=;\r\n"
  -&gt; "Server_Id: bo1.200.21\r\n"
  -&gt; "TXID: CuDIFVkCOX1KINAaSrUgAg==\r\n"
  -&gt; "\r\n"
  -&gt; "64\r\n"
  reading 100 bytes...
  -&gt; "[{\"code\":400,\"message\":\"Bad Request: Content-Type not supported: \"}]Encoding type  is not supported."
  read 100 bytes
  reading 2 bytes...
  -&gt; "\r\n"
  read 2 bytes
  -&gt; "0\r\n"
  -&gt; "\r\n"
  Conn close
  #&lt;Net::HTTPBadRequest 400 Bad Request readbody=true&gt;
  </code></pre>
  
  <p>Can someone help me out?</p>