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": ""
       }
    })
})
user2345
  • 63
  • 1
  • 10
  • 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 Oct 26 '21 at 20:06
  • i need a sent a image, for example image.png like that – user2345 Oct 26 '21 at 20:23
  • That sounds like sending form data. Is this what you want? Perhaps you need to look at this https://github.com/cypress-io/cypress/issues/1647 there are examples of this case and how peopel solved it. – pavelsaman Oct 26 '21 at 20:33

0 Answers0