I’m trying to test the functionality of a webservice using ruby with minitest and Net:HTTP.
This code
class TestOne < MiniTest::Unit::TestCase
load 'test/test_helper.rb'
def test_one
xml_to_transmit = "
<?xml version='1.0' encoding='UTF-8' ?>
<MyRequest version='1.0'>
<Id>1</Id>
</MyRequest>"
url = URI('http://example.com/api')
resp, data = Net::HTTP.post_form(url,nil => xml_to_transmit)
end
end
will escape the xml that I’m trying to send to the server as a parameter. Is there a way to send it unescaped? (I have no possibility to change the serverside code.)
This is the parameter as it is received by the server
=%0A%3C%3Fxml+version%3D%271.0%27+encoding%3D%27UTF-8%27+%3F%3E%0A%3CMyRequest+version%3D%271.0%27%3E%0A%09%3CId%3E1%3C%2FId%3E%0A%3C%2FMyRequest%3E
My test_helper.rb is quite basic
require 'minitest/unit'
require 'minitest/autorun'
require 'net/http'
Does anyone have any ideas on why this is happening and what I could do about it?
This should work: