REST Client – simple DSL for accessing HTTP and REST resources
A simple HTTP and REST client for Ruby, inspired by the Sinatra’s microframework style of specifying actions: get, put, post, delete.
- Main page: github.com/rest-client/rest-client
I found this Ruby-Gem very useful while building App. so i will describe here how to use REST Client in Ruby
Simple example for REST Client POST Request.
require 'rest_client' res=RestClient.post 'http://localhost:8080/wm/test/json', params.to_json, :content_type => :json, :accept => :json result = JSON.parse(res) return result.to_json
above example send post request to my local server, which takes few parameters in form of json and
result.to_json
return output in form of JSON.
likewise, you can use any method GET,PUT,DELETE.
Hope you’ll like dis 🙂
Hey nice code snippet. Thanks for that. How did you setup your server to handle the data send by your app and create a response?
For a new programmer using the rails framework. Where would I place this code within the framework?