Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST with ruby?

Tags:

rest

ruby

Are there good references teaching you how to send PUT/DELETE/POST/GET with ruby?

I have looked at Net::HTTP.

Is this library capable of all four methods? I couldn't find how to send with PUT.

Are there other good libraries for all these four methods?

like image 772
never_had_a_name Avatar asked Mar 15 '26 14:03

never_had_a_name


2 Answers

You should definitely look at HTTParty. It's an easy to use library to deal with RESTful requests, JSON responses and so forth.

like image 130
Daniel O'Hara Avatar answered Mar 18 '26 07:03

Daniel O'Hara


The simplest way would probably be to use the rest client gem. Then you can do stuff like

RestClient.get 'http://example.com/resource', {:params => {:id => 50, 'foo' => 'bar'}}

EDIT: changed url to a more up to date one.

like image 20
yxhuvud Avatar answered Mar 18 '26 08:03

yxhuvud



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!