Open CarolinaSL opened 1 year ago
will create support for this soon đź‘Ť thanks for the report. one question - before .then()
command, do you use cy.fixture()
 to load the file?
Yes, I use cy.fixture()
to load the file. I appreciate your effort, thanks!
Does it matter if you import a file by
import fileName from '../../fixtures/fileName.json';
or cy.fixture()
?
it seems that the formData
on its own is not the core of the problem. I have been able to work OK with the following test:
it('uploads a file', () => {
cy.fixture('logo.png', 'binary').then(image => {
const blob = Cypress.Blob.binaryStringToBlob(image, 'image/png');
const formData = new FormData();
formData.append('image', blob, 'logo.png');
cy.api({
method: 'POST',
url: '/',
body: formData,
headers: {
'content-type': 'multipart/form-data'
},
})
})
});
it doesn’t do too much, but it does not throw the error. is it possible for you to provide an example of what the response for such API call is?
I'm facing the same issue and it seems to be related to the API response processing. Not the request.
Here is the response from my API:
413 Request Entity Too Large 413 Request Entity Too Large
nginx
Seeing the same issue. I am using a fixture and modifying some objects in the json before passing to the endpoint. The operation itself seems successful as I can see the desired values changed in my application but I get the above mentioned error at the end. There is no error when using cypress native method
cy.fixture('').then((data) => {
data.key1 = some value;
cy.putWithTokenAPI(urlPath, accessToken, data).then((response) => {
expect(response.status).to.eq(200);
});
});
Hello! I'm with problems when I try to send a blob file through formData. The error returned is the following:
Some points :
-The same error is obtained using requestMode.
Cypress version: 12.1.0 Cypress-api-plugin version: 2.9.0
Here is the piece of code: