Multipart REST post, XML body with file

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”>true3456</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