title: Posting Ruby data in JSON format with Net/http
body: <p>I have this ruby file:</p>
  
  <pre><code>require 'net/http'
  require 'json'
  require 'uri'
      #test data
  
  newAcctJson ='{
    "type": "Credit Card",
    "nickname": "MoreTesting",
    "rewards": 2,
    "balance": 50
  }'
  
      #creates a new account
  def createAcct(custID, json)
      url = "http://api.reimaginebanking.com:80/customers/#{custID}/accounts?key=#{APIkey}"
      uri = URI.parse(url)
      http = Net::HTTP.new(uri.host, uri.port)
      myHash = JSON.parse(json)
      resp = Net::HTTP.post_form(uri, myHash)
      puts(resp.body)
  end
  </code></pre>
  
  <p>which attempts to create a new account. However I get <code>code: 400, invalid fields in account</code>. I tested the data independently, so I'm (relatively) certain that the json itself isn't in an incorrect format; the problem is in trying to submit the data in the hash format that the <code>post_Form</code> requires. Does anyone know a way to use ruby to directly post json data without converting to a hash first?</p>