1

Above given my upload code, how can I upload file in API automation

it('upload',function(){
       const token = Cypress.env('token');    
        cy.request({
           method:'POST',
          url:"/file/upload",
          headers: {
           authorization : 'Bearer ' + accessToken
          },
          body: {
           "file": ""
       }
    })
})
3
  • What do you mean file in this context? Your Cypress example sends a plain text http payload formatted as JSON. Do you want to send a file name? Or what does your endpoind expect?
    – pavelsaman
    Commented Oct 26, 2021 at 20:06
  • i need a sent a image, for example image.png like that
    – user2345
    Commented Oct 26, 2021 at 20:23
  • That sounds like sending form data. Is this what you want? Perhaps you need to look at this github.com/cypress-io/cypress/issues/1647 there are examples of this case and how peopel solved it.
    – pavelsaman
    Commented Oct 26, 2021 at 20:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.