acacia acacia - 10 months ago 105
Ruby Question

wrong status line: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">"

I am getting a weird error when i make http request.

The request code is like this;

purchase_xml = Transaction.yo_xml(api_username,api_password,@total, account, merchant_reference)
uri = URI.parse(url)
http =, uri.port)
request =
request.body = purchase_xml
response = http.request(request)
result = Hash.from_xml(response.body)

Where the yo_xml looks like this;

def self.yo_xml(api_username, api_password,amount, account, transaction_id)
xml = "<?xml version=1.0 encoding=UTF-8?><AutoCreate><Request><APIUsername>#{api_username}</APIUsername>
<Account>#{account}</Account><Narrative>Purchase of SMS</Narrative><InternalReference>#{transaction_id}</InternalReference>
<ExternalReference>#{transaction_id}</ExternalReference><ProviderReferenceText>Thank you for using Skyline SMS</ProviderReferenceText>
return xml

I am getting this error;

wrong status line: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">"

raised o this line

response = http.request(request)

Any help is appreciated.

Answer Source

I have gotten an error similar to this before trying to access a resource over https. You didn't mention if that was the case, but if so setting http.use_ssl = true before the post might fix it.