简体   繁体   中英

http POST error

I'm trying to send the xml to another webserver through Restclient's 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'm getting 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've been told that I am receiving that error because the XML file is not in the content of the call. It must be in the content. I have no idea what does this mean.

Any suggestion / clue will be greatly appreciated.

Thanks

You should be doing 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' )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM