Convert curl command to Ruby http POST(xml) with headers Convert curl command to Ruby http POST(xml) with headers curl curl

Convert curl command to Ruby http POST(xml) with headers


Try this:

uri = URI("sample_url")xml = 'sample xml'req = Net::HTTP::Post.new(uri, 'Content-Type' > 'text/xml', 'Content-length' => xml.length,'Connection' => 'close')req.body = xmlres = Net::HTTP.start(uri.hostname, uri.port) {|http|  http.request(req)}