DEV Community

Cover image for πŸ”₯ How to Upload File in Rest Assured(with Download)?
Pramod Dutta
Pramod Dutta

Posted on

πŸ”₯ How to Upload File in Rest Assured(with Download)?

In this video, We are going to learn How to upload a file in rest assured and download file in rest assured.

Rest Assured upload file is easy and can be achieved with the multipart inbuilt methods.

βœ… Quick Code -
.multiPart("file", new File(TestUtil.getFileURI("/examples/help.html")), "text/html")
https://stackoverflow.com/questions/39482473/how-to-use-rest-assured-to-upload-a-file

We will assume that a post method "https://the-internet.herokuapp.com/upload" uploads an image for a user. Lets take a look at the below example on how to upload the image file using POST call.

We will use the function that takes 3 parameters.

  • The key that identifies the file.
  • File object.
  • Content type.

We Use POST request to perform this operation.

βœ… Source Code.

βœ… What is REST Assured?
REST Assured is a Java library that provides a domain-specific language (DSL) for writing powerful, maintainable tests for RESTful APIs. ... I'll be using real-world code examples you can copy, run, and reuse directly in your own test automation effort

🌍 Test Automation -
https://bit.ly/learnautomation2020

πŸ’Œ API Testing -
https://www.learnapitesting.com

πŸŽ™ Cypress Tutorial with LIVE Projects -
https://cypresstutorial.com

πŸ“ REST API testing with Python -
https://masterapitesting.com

Top comments (0)