cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Response body is dropped for multipart POSTs

Open manuhortet opened this issue 2 years ago • 1 comments

Current behavior

I am sending a multipart POST. The request is formed correctly and reaches the server. The response is also sent as expected form the server. But for some reason the response body seems to be dropped. See code below for the exact request.

When doing .debug() after the cy.request() I can see that the body is an ArrayBuffer. With other POST requests I'm doing this doesn't happen, the response body there appears in the debug information as a JSON.

image

Test code to reproduce

cy.readFile('cypress/fixtures/dummy.pdf', 'binary')
      .then((binary) => Cypress.Blob.binaryStringToBlob(binary))
      .then((blob) => {

        const formData = new FormData()
        formData.append('file', blob, 'dummy.pdf')
        formData.append('parent', parentUuid)

        cy.request({
          method: 'POST',
          url: 'http://localhost:8000/api/upload/',
          body: formData,
        }).then((response) => {

        // response.body here is {}, but I am sure the server is sending something else

})

Cypress Version

10.3.1

Node version

19.0.1

Operating System

macOS 13

manuhortet avatar Nov 18 '22 11:11 manuhortet

possibly related to https://github.com/cypress-io/cypress/issues/24560.

@manuhortet I'm sorry you are having difficulties. Can you try the workaround in the above linked ticket and see if that fixes your problem for the short term while we investigate further? Thank you.

nagash77 avatar Nov 18 '22 19:11 nagash77

Unfortunately we have to close this issue due to inactivity. Please comment if there is new information to provide concerning the original issue and we can reopen.

mike-plummer avatar Dec 07 '22 21:12 mike-plummer