ruby httparty get response url or id after post

Viewed 6818

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

3 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"
Related