When doing interface tests , There is often an interface for uploading files , I'll teach you how to use it today apipost Interface testing tools and python+requests Script for interface testing .
One 、 Use python+requests
python+requests When testing the interface of document upload , Need to call files, However, you need to pay attention to the format of the description path when reading and uploading files , because window To read a file, you can use \, But in the string \ Is used as an escape character .
Three solutions ：
1. The way of escape
2. Explicitly declare that the string does not need to be escaped
3. Use Linux The path of /
python+requests Interface test script
Two 、 Use apipost Interface test tool for file upload
open apipost, Input url, hold body Inside text Change it to file, Select the file to upload . Click send to upload the interface file .