Hi
I need to post some xml info to a restful api can anyone give me a clue of how to do this? I'm using rails.
Thanks in advance
Hi
I need to post some xml info to a restful api can anyone give me a clue of how to do this? I'm using rails.
Thanks in advance
In rails, using ActiveResource, you do it like this:
class PersonResource < ActiveResource::Base
self.site = "http://api.people.com:3000/"
self.proxy = "http://user:[email protected]:8080"
end
ryan = Person.new(:first => 'Ryan', :last => 'Daigle')
# the next line posts this object serialized to xml to the configured url
ryan.save # => true
http://api.rubyonrails.org/classes/ActiveResource/Base.html
If the site you are posting to has a custom API (not active resource) you must use Net:HTTP