400 bad request in ruby but not curl 400 bad request in ruby but not curl curl curl

400 bad request in ruby but not curl


For me the problem was not making the request over SSL. Once I set the following line everything worked:

http.use_ssl = true

This wasn't the OPs problem, but I'm posting anyway because the error message is the same and this thread is one of the top google hits for the error.


you should specify full url:

req = Net::HTTP::Post.new("https://api.parse.com/1/push")


def get_job(job_name)        puts "Posting job #{job_name} to get test update order service"        get_job_xml ="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://os.uk/Test/GetUpdateOrders/1.0\">       <soapenv:Header/>       <soapenv:Body>          <ns:GetTestUpdateOrdersReq>             <ContractGroup>abc</ContractGroup>             <ProductID>myproduct</ProductID>             <Reference>#{job_name}</Reference>          </ns:GetTestUpdateOrdersReq>       </soapenv:Body>    </soapenv:Envelope>"        @http = Net::HTTP.new(@server, @port)        request = Net::HTTP::Post.new(('/XISOAPAdapter/MessageServlet?senderParty=&senderService=faceNamespace=http://myco.uk/Test/GetUpdateOrders/1.0'), initheader = {'Content-Type' => 'text/xml'})        request.basic_auth(@username, @password)        request.content_type='text/xml'        request.body = get_job_xml        response = @http.request(request)      end  

I have defined my method like this and its working.