Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby httparty get response url or id after post

Tags:

ruby

httparty

How can I get the response url or id from a rails project with httparty in a separate script after doing a post?

ruby script:

  HTTParty.post('http://localhost:3000/change_logs', parameters)

response.body and all the others ones do not show the url and the response id

like image 351
nictrix Avatar asked Aug 23 '10 07:08

nictrix


1 Answers

Two years later, I found a way to access the last URI from the request attribute on the response:

url      = "http://example.com/redirects/to/www"
response = HTTParty.get(url)
response.request.last_uri.to_s
# => "http://www.example.com"
like image 190
Avand Amiri Avatar answered Sep 19 '22 09:09

Avand Amiri