Forum: Ruby on Rails RestClient send method?

1d4a45a695b48edc70359ca6d015e2f4?d=identicon&s=25 John Merlino (johnmerlino)
on 2011-05-06 02:53
Hey all,

I see this line of code:

RestClient.send(verb, url, parameters)

Basically there's two rails application that communicate with each
other. RestClient is a rails gem. Here we send the get http verb and a
url string comprising of the other application base url and append a
query string to it consisting of the new user email that is being
created. So if the arguments are these:

RestClient.send(:get,
www.otherapp.com/users/email?email=johnmerlino@gmail.com)


What exactly would RestClient get back as the response? I don't mean
this specific case, but I mean what is supposed to be sent back to
client in general. Or even if it is the ruby send
method, what exactly is RestClient doing with these two parameters?

I looked in documentation:

https://github.com/archiloque/rest-client

and it didn't give a clear answer. The documentation shows you how to
use it but it doesn't explain why you would want to do something about.
Before I understand how to use it, I think I need to know why. It
appears to have nothing to do with cookies and that's typically how you
can maintain a browser state from one app to the next.

Thanks for response.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2011-05-06 09:07
(Received via mailing list)
On 6 May 2011, at 01:53, John Merlino <lists@ruby-forum.com> wrote:

> created. So if the arguments are these:
> I looked in documentation:
>
> https://github.com/archiloque/rest-client
>
> and it didn't give a clear answer.

Which bit of

for results code between 200 and 207 a RestClient::Response will be
returned
for results code 301, 302 or 307 the redirection will be followed if the
request is a get or a head
for result code 303 the redirection will be followed and the request
transformed into a get
for other cases a RestClient::Exception holding the Response will be
raised, a specific exception class will be thrown for known error codes
Is not clear?


> The documentation shows you how to
> use it but it doesn't explain why you would want to do something about.
> Before I understand how to use it, I think I need to know why. It
> appears to have nothing to do with cookies and that's typically how you
> can maintain a browser state from one app to the next.
>
It sends http requests. Why you would want to send http requests is up
to you

Fred
B74644db03ee70d45b81bd775956d252?d=identicon&s=25 Eugen Ciur (eugen)
on 2011-05-06 09:46
John,

RestClient is a thin wrapper fot Net::HTTP standard library

 http://www.ruby-doc.org/stdlib/libdoc/net/http/rdo...

And it assumes that you already know how to use it and why; it just
simplifies (if you know how to use Net::HTTP) usage of Net:HTTP.

My advice is instead of getting stuck at RestClient documentation look
at documentation for Net::HTTP and only then jump directly to RestClient
source code, which is pretty simple and self explanatory; you don't
event have to go to source code in your local gem, just use github:

https://github.com/archiloque/rest-client/tree/mas...

Hope it helps.

----
http://blog.eugen.co
1d4a45a695b48edc70359ca6d015e2f4?d=identicon&s=25 John Merlino (johnmerlino)
on 2011-08-31 19:09
thanks for responses
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.