Reputation: 25348
What's the shortest/simplest way to send a POST call to an external URL from a Rails app?
I need to send a POST request to a URL like this:
http://api.example.com/aff?id=12345&sub=123456
Upvotes: 2
Views: 1124
Reputation: 13097
Here's a good example: How do I post XML to RESTFUL Web Service using Net::HTTP::Post?
url = URI.parse('http://api.example.com/aff?id=12345&sub=123456')
request = Net::HTTP::Post.new(url.path)
response = Net::HTTP.start(url.host, url.port) {|http| http.request(request)}
Upvotes: 2