Hi,
Can anyone shed light on how to do a classic RAILS REST POST (i.e.
post an XML structure representing an ActiveResource) ... whilst at
the same time posting a file?
My current code (working) is below. It does not have a file associated
with the post.
I know I have to do a multipart, but what I cant work out is that in a
multipart, each value has a key ... what would be the key for the main
XML body? Because, see, in the example below, the XML _is_ the body
... it has no key associated with it.
Etienne
----------------------------------------------------------
body = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?><my_object><someValue
type=\"boolean\">true</someValue><someOtherValue>3456</someOtherValue</my_object>"
uri = URI.parse("http://#{$SITE_URL}/my_object.xml")
http = Net::HTTP.new(uri.host, uri.port)
headers={}
headers[''Content-Type''] = "application/xml"
begin
http.start do
req = Net::HTTP::Post.new(uri.request_uri, headers)
req.basic_auth($name, $pword)
resp = http.request(req, body)
if resp.is_a?(Net::HTTPSuccess)
return true
else
return false
end
end
rescue Exception => e
debug "Exception with submitting using net:http #{ e } (#{ e.class
})!"
return false
end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---