Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin doesn't show the json response after using formData as request body #128

Open
Maria-Pahome opened this issue Sep 20, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@Maria-Pahome
Copy link

No description provided.

@filiphric filiphric added the bug Something isn't working label Jul 14, 2024
@filiphric
Copy link
Owner

hey @Maria-Pahome could you please give me an example of how you use formdata with this plugin? it would help me investigate and fix the issue

@LaritaStevanovic
Copy link

I am having this same issue, I used formData and Blob to upload file through API and I am not getting any json response. Also request body is showing empty array in runner.

        cy.fixture('Screenshot 2024-07-12 at 10.13.51 (1).png', 'binary').then((fileContent) => {

            const blob = Cypress.Blob.binaryStringToBlob(fileContent, 'image/png')
        
            const formData = new FormData()
            formData.append('file', blob, 'Screenshot 2024-07-12 at 10.13.51 (1).png')
            
            cy.api({
                method: 'POST',
                url: `${Cypress.env('apiBaseUrl')}/files`,
                failOnStatusCode: false,
                headers: {
                    'Accept': 'application/json',
                     Authorization: 'Bearer ' + `${Cypress.env('SuperUserToken')}`,
                },
                body: formData
                
            })
            .then(response => {
                expect(response.status).to.eq(200)
})
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants