Reputation: 4717
I need to access a REST JSon Service. It's just connecting to an HTTPS using Basic authentication and performing some GETs and POSTs. This is a Ruby script running from a crontab.
These are the requirements:
Should I use HTTParty? I tried to install the gem and use it from irb with no luck. Apparently it has some dependencies. Should I go for other library like net/http?
If HTTParty is the way to go, can you please include some instructions on how to get it to work in an IRB console?
Upvotes: 1
Views: 1037
Reputation: 29960
ActiveResource might do the trick in a more elegant way than HTTParty.
Upvotes: 1
Reputation: 3011
Whenever I am connecting to a REST/JSON/API or just a site directly I go for HTTParty / Merhanize / Nokogiri depending on what exactly I need to do with the site. I also would be sure to check Ruby Toolbox in their HTTPClient category for other popular gems.
>> require "httparty"
=> true
>> response = HTTParty.get("http://justinherrick.com/posts/what-it-means-to-stay-dry.json")
=> #<HTTParty::Response:0x104ceac70 @parsed_response={"slug"=>"what-it-means-to-stay-dry", "pubdate"=>"2012-02-06", "created_at"=>"2012-02-06T22:08:05+00:00", "category"=>"Programming", "title"=>"What it means to stay DRY", "body"=>"A very common and useful programming idiom...
Upvotes: 2