Nadia Volnovsky
Nadia Volnovsky

Reputation: 1

Cypress send XML requests (SOAP API)

i have tried to send my XML as request . it looks like this:

let requestBody = function (method){ 
return "<x:Envelope"
+"xmlns:x='someurl'"
+"xmlns:inf='someurl'>"
  +"<x:Header/>"
    +"<x:Body>"
        +"<inf:"+method+"></inf:"+method+">"
            +"</x:Body>"
               +"</x:Envelope>" }
"\n<x:Envelope"+


Cypress.Commands.add("getReports", (soapAction) => {
    var parseXML
    var action=requestBody(soapAction)
      cy.fixture('urlFixture').then((url)=>{
      cy.request({
        method: 'POST',
        url: url.indoDistV1,
        headers: {
            soapAction:url.actionStartAdress+soapAction,
            "ContentType":"text/xml; charset=utf-8"

        },
        body: requestBody(soapAction)
    })
})
})

and the response was 415 is anybody know what is wrong?

thank you

Upvotes: 0

Views: 2148

Answers (1)

Aysha Mohamed Rafiq
Aysha Mohamed Rafiq

Reputation: 19

I think the "ContentType":"text/xml; charset=utf-8" should be change to "Content-Type":"text/xml; charset=utf-8"

Upvotes: 1

Related Questions