This should work:
begin
RestClient.post url, :param => p
rescue Redirect => e
redirected_url = e.url
end
Update
Since the above did not work, I suggest you try:
RestClient.post(url, :param => p) do |response, request, result, &block|
if [301, 302, 307].include? response.code
redirected_url = response.headers[:location]
else
response.return!(request, result, &block)
end
end
(this is a combination of the suggested implementation of how to follow redirection on all request types and Request
's implementation of follow_redirection