Skip to content

Instantly share code, notes, and snippets.

@danielhopkins
Created May 16, 2014 16:00
Show Gist options
  • Save danielhopkins/d91c75e14a8d09c78ed9 to your computer and use it in GitHub Desktop.
Save danielhopkins/d91c75e14a8d09c78ed9 to your computer and use it in GitHub Desktop.

Revisions

  1. Dan Hopkins created this gist May 16, 2014.
    26 changes: 26 additions & 0 deletions foo.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/usr/bin/env ruby

    require 'rubygems'
    require 'json'
    require 'uri'
    require 'net/http'

    json = [
    {:foo => "bar"},
    {:foo => 'chicken'},
    {:foo => 123},
    {:foo => 123.00000},
    {:bar => "bot"}
    ]


    json.each do |body|
    uri = URI("http://requestb.in/ub1oi4ub")
    http = Net::HTTP.new(uri.host, uri.port)

    r = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})
    r.body = JSON.generate(body)
    response = http.request(r).code

    puts response
    end