Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 402
safalmj Avatar asked Nov 13 '22 20:11

safalmj


1 Answers

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' )
like image 137
Maurício Linhares Avatar answered Dec 24 '22 09:12

Maurício Linhares