Ruby on rails http POST错误
我正试图通过Restclient的http POST请求将xml发送到另一个Web服务器。代码如下:Ruby on rails http POST错误,ruby-on-rails,xml,http-post,Ruby On Rails,Xml,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") 但我得到了这个错误 ERR
response = RestClient.post 'https://secure.rowebooks.co.uk/testorders/orders.aspx', :content_type => "text/xml", :myfile => File.read("#{Rails.root}/public/shared/#{@book}.xml")
但我得到了这个错误
ERROR 2 Data at the root level is invalid. Line 1, position 1.ERROR3 Object reference not set to an instance of an object.
我被告知我收到了这个错误,因为XML文件不在调用的内容中。它必须在内容中。我不知道这是什么意思
如有任何建议/线索,将不胜感激
谢谢你应该这样做:
response = RestClient.post( 'https://secure.rowebooks.co.uk/testorders/orders.aspx',
File.read("#{Rails.root}/public/shared/#{@book}.xml"), 'Content-Type' => 'text/xml' )
您好,谢谢您的回复,但您发布的代码返回错误-“语法错误,意外'\n',预期为tASSOC”。少了什么吗?非常感谢毛里西奥。我非常感谢你的帮助。