HttpRunner httprunner 怎么测试上传图片的接口?

null · May 16, 2019 · Last by null replied at June 21, 2019 · 867 hits

RT

共收到 4 条回复 时间 点赞
name: 
request:
files:
file: ['xxx.jpg',$file,'image/jpeg']
method: POST
2Floor has been deleted
JKzhishui 回复

麻烦问下,运行接口提示文件参数,参数错误,,我格式设置哪有问题呢

格式设置

得到的请求参数:
'request': {
'url': 'https://XXXXXXXX/lyy/rest/group/distributor/saveMaterial',
'method': 'POST',
'verify': False,
'headers': {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Cookie': 'SESSION=62d8504a-fa89-49da-b506-bac396937cba; Path=/lyy/; HttpOnly'},
'data': {'name': 'ttr', 'price': 3, 'id': '', 'materialType': '1000020', 'description': 'dddd'},
'files': {'imageUrl': ['7.jpg', 'D:\PGRunner\PGRunner\static\images\7.jpg']}
}

我那个是在httprunner里面的yml文件运行的。如果你要在IDE的话,尝试requests-toolbelt
文档:https://toolbelt.readthedocs.io/en/latest/user.html#multipart-form-data-encoder

null #5 · June 21, 2019 作者
JKzhishui 回复

$file 是什么。

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up