HTTP POST Error

I am trying to send xml to another web server via Restclient http POST request. This is the code:

response =  RestClient.post 'https://secure.rowebooks.co.uk/testorders/orders.aspx', :content_type => "text/xml", :myfile => File.read("#{Rails.root}/public/shared/#{@book}.xml")

But I get this error

ERROR 2 Data at the root level is invalid. Line 1, position 1.ERROR3 Object reference not set to an instance of an object.

I was told that I am getting this error because the XML file is not in the contents of this call. It should be in the content. I have no idea what that means.

Any suggestion / hint is welcome.

thank

+5
source share
1 answer

You should do it like this:

response =  RestClient.post( 'https://secure.rowebooks.co.uk/testorders/orders.aspx', 
File.read("#{Rails.root}/public/shared/#{@book}.xml"), 'Content-Type' => 'text/xml' )
+1
source

All Articles