注意 - 我已经检查过BlazeMeter 教程 https://www.blazemeter.com/blog/testing-advanced-rest-api-file-uploads-jmeter当我使用“文件上传”选项卡时,它将文档作为正文数据上传。
这是我的请求的样子 -
执行时我收到以下请求 -
POST https://xxx
POST data:
<actual file content, not shown here>
[no cookies]
Request Headers:
Connection: keep-alive
Content-Type: multipart/form-data
Accept-Language: en-US
Authorization: bearer <>
Accept: application/json
Content-Length: 78920
Host: test-host
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_102)
并且请求失败并出现 400 错误 -
Response code: 400
Response message: Bad Request
由于我能够使用curl进行文件上传,我假设我错过了JMeter的一些配置。卷曲看起来像 -
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Authorization: Bearer <>' -F upload_file=@"test.pdf" 'https://xxx'
我在 JMeter 文件上传中错过了什么?
另一次投票支持在 Jmeter 的“高级”选项卡中使用 Java 实现。我的 headers 和 body 在 postman 和 jmeter 之间完全相同,但它不会上传我的文件(得到响应代码 415),直到我更改为 Java 实现。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)