Post post Submission with Axios

Asked

Viewed 665 times

1

Hello, I’ve been bumping my head to solve a problem with sending a POST request from a SOAP envelope with Xios, I send the same XML with the same Reset by POSTMAN and it works pretty good, but when I do the same upload with Axios it returns an Exception with no return, with the status 400, Bad request.

create(data) {
const url = 'http://qmcext.no-ip.org:8080/questECC/WebServices/WorkflowEngineSOA.asmx'

const xml = `
<?xml version=\"1.0\" encoding=\"utf-8\"?>
  <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">
      <soap:Body>
          <createCasesAsString xmlns=\"http://tempuri.org/\">
              <casesInfo>
                  <![CDATA[
                  <BizAgiWSParam>
                      <domain>domain</domain>
                      <userName>oten</userName>
                      <Cases>
                          <Case>
                              <Process>${'TesteSOA'}</Process>
                              <Entities>
                                  <ZohoDocs>
                                    <radNumber>${'VA030688'}</radNumber>
                                    <dataEntrada>${'2018-03-06'}</dataEntrada>
                                        <fileZoho>
                                          <File fileName="${data.file.originalname}">${Buffer.from(data.file.buffer).toString('base64')}</File>
                                        </fileZoho>
                                    </ZohoDocs>
                              </Entities>
                          </Case>
                      </Cases>
                  </BizAgiWSParam>
                  ]]>
              </casesInfo>
          </createCasesAsString>
      </soap:Body>
  </soap:Envelope>`

const headers = {
  'Content-Type': 'text/xml;charset=UTF-8',
  'soapAction': 'http://tempuri.org/createCasesAsString'
}

return new Promise((resolve, reject) => {
  axios
    .post(url, xml, { headers })
    .then(({ data }) => resolve(data))
    .catch(err => reject(err.response))
    })
 }

The answer I get is very big but the Statuscode is :400 and the Statusmessage is: Bad Request

the parameter data of the answer is empty

  • 1

    Can you catch the CURL for POSTMAN so I can test here?

  • 1

    It will be problem of CORS?

  • @Sergio It’s an API, as to using localhost:3000 may be that this is actually happening

  • @Sorack How I get the CURL by the Postman?

  • @Gabriel https://learning.getpostman.com/docs/postman/sending_api_requests/generate_code_snippets/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.