我正在嘗試在 JMeter 中上傳帶有字串的檔案。它不起作用
POST http://localhost:8080/upload
POST data:
--v2IM1VsVLV5EbtspRzGOSrHaDQb-mlef6r
Content-Disposition: form-data; name="input"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
{ "name": "John", "country": "US" }
--v2IM1VsVLV5EbtspRzGOSrHaDQb-mlef6r
Content-Disposition: form-data; name="file"; filename="sample.txt"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
<actual file content, not shown here>
--v2IM1VsVLV5EbtspRzGOSrHaDQb-mlef6r--
[no cookies]
使用 JMeter 時出現以下錯誤
{"code":"ERROR","message":"Required request parameter 'input' for method parameter type String is not present"}
我可以使用 curl 或 Postman 來滿足請求,而不會出現任何問題。這是我的卷曲請求。
curl -i -X POST \
-H "Content-Type:multipart/form-data" \
-F "file=@\"./sample.txt\";type=text/plain;filename=\"sample.txt\"" \
-F "input={ \"name\": \"John\", \"country\": "US" }" \
'http://localhost:8080/upload'
uj5u.com熱心網友回復:
如果您能夠使用 Postman 成功執行請求,您應該能夠使用 JMeter 的
將sample.txt檔案復制到 JMeter 安裝的“bin”檔案夾中
在 Postman 中運行您的請求
JMeter 將捕獲請求并生成正確的HTTP 請求采樣器
更多資訊:如何將 Postman API 測驗轉換為 JMeter 以進行縮放
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/405325.html
標籤:
下一篇:查詢選擇器排序
