title: How do I post JSON via HTTP in Ruby after conversion from Python?
body: <p>I yield - I've tried for hours to crack this nut but can't figure it out.  I'm too new to Ruby (and have no Python background!) to translate this and then post my JSON data to a site that requires user/pass, and then get the response data.</p>
  
  <p>This is the Python code:</p>
  
  <pre><code>r = requests.post('https://keychain.oneid.com/validate/', json.dumps(data), auth=('username', 'password'))
  r.json()
  </code></pre>
  
  <p>where <code>data</code> is:</p>
  
  <pre><code>{"some" =&gt; "data", "fun" =&gt; "times"}
  </code></pre>
  
  <p>I'm trying to replicate the functionality of this code in Ruby for use with a Rails application, but between figuring out how the Python <code>requests.post()</code> function operates and then writing the Ruby code for POST and GET, I've become totally lost.</p>
  
  <p>I tried Net::HTTP but I'm not clear if I should be putting the username/pass in the body or use the <code>basic_auth</code> method -- <code>basic_auth</code> seems to only work inside <code>Net::HTTP.get</code> ... and Net::HTTP doesn't seem to easily handle JSON, but again, I could be totally out to lunch at this point.</p>
  
  <p>Any suggestions or help would be greatly appreciated!</p>