http POST错误

saf*_*lmj 5 xml ruby-on-rails http-post

我正在尝试通过Restclient的http POST请求将xml发送到另一个Web服务器.这是代码:

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

但是我收到了这个错误

ERROR 2 Data at the root level is invalid. Line 1, position 1.ERROR3 Object reference not set to an instance of an object.
Run Code Online (Sandbox Code Playgroud)

我被告知我收到该错误,因为XML文件不在调用的内容中.它必须在内容中.我不知道这是什么意思.

任何建议/线索将不胜感激.

谢谢

Mau*_*res 1

你应该这样做:

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