Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
WinHttpRequest / Microsoft.XMLDOM vs. Cypress.Request POST

I apologize in advance for this poorly worded question.

I'm re-writing an older E2E test that performs a POST of an XML document to an internal site using vbScript. With WinHttpRequest and Microsoft.XMLDOM the data is accepted and appears as expected in the website. However, when I perform the "same" operation using Cypress I obtain different results.

My question: Is there difference in the way these two technologies perform the POST operation or am I missing something in the Cypress code?

Thanks in advance for any advice!

VBS

Dim xmlhttp, oXML
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "POST", "https://InternalWebSite.com/Orders/CXMLOrder.aspx", False
xmlhttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded; charset=UTF-8"
xmlhttp.setRequestHeader "Content-length", "1000"
xmlhttp.setRequestHeader "Connection", "close"
xmlhttp.setRequestHeader "soapAction", ""
Set oXML = CreateObject("Microsoft.XMLDOM")
oXML.async = False
oXML.load(localPath & "\MyOrderFile.xml")
xmlhttp.send(oXML)

CYPRESS

it('Post Order File to Site', () => {
    const myOrderFile = 'C:\\Automation\\MyOrderFile.xml'
    cy
        .readFile(myOrderFile)
        .then(function (text) {
            cy.log(text)
            postXML(text)
         })
    })

function postXML(text) {
    return cy.request({ 
        url: 'https://InternalWebSite.com/Orders/CXMLOrder.aspx',
        method: 'POST',
        body: text,
        headers: {
            'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'content-length': '1000',
            'connection': 'close',
            'soapAction': ''
        }
    }
)}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The solution ended up being quite simple.

In the original VBS code the "content-length" was set to 1000 - my assumption was that if it worked for VBS it would also work for Cypress. As it turns out setting "content-length" based on the actual XML payload length was the trick.

From: 'content-length': '1000',

To: 'content-length': text.length,

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!