【发布时间】:2018-08-16 03:13:16
【问题描述】:
我在 Jmeter 中上传文件(例如 Upload.txt)和 JSON 数据时遇到困难。
查看结果树中的请求
POST http://localhost:8080/xxxx/custom/uploaddocument
POST data:
--jmeter_is_great
Content-Type: application/json; charset=UTF-8
{
"Document": {
"documentName": "TEST.txt",
"fullPath": "Test",
"priority": "M",
"referenceNo": "Ref12345",
"descrption": "Testfile",
"userDef1": "",
"userDef2": "",
"userDef3": "",
"userDef4": "",
"userDef5": "",
"userDef6": "",
"userDef7": "",
"userDef8": "",
"userDef9": "",
"userDef10": "",
"profile": {
"id": -2,
"index": [{
"id": -7,
"value": "Signature",
"type": "D"
}]
},
"ACL": {
"isInherit": false,
"permission": [{
"permissionType": "U",
"userID": 10001,
"groupID": "",
"roleID": "",
"permissionString": "ROPKFIAENTCMDHZVWGLUSB",
"mustFlag": false
}]
}
}
}
--jmeter_is_great
Content-Type: text-plain
THIS IS TESTING FILE CONTENT
--jmeter_is_great--
[no cookies]
Request Headers:
Connection: keep-alive
Content-Length: 876
Content-Type: multipart/related; boundary=jmeter_is_great
POST http://localhost:8080/xxxx/custom/uploaddocument
POST data:
--jmeter_is_great
Content-Type: application/json; charset=UTF-8
{
"Document": {
"documentName": "TEST.txt",
"fullPath": "Test",
"priority": "M",
"referenceNo": "Ref12345",
"descrption": "Testfile",
"userDef1": "",
"userDef2": "",
"userDef3": "",
"userDef4": "",
"userDef5": "",
"userDef6": "",
"userDef7": "",
"userDef8": "",
"userDef9": "",
"userDef10": "",
"profile": {
"id": -2,
"index": [{
"id": -7,
"value": "Signature",
"type": "D"
}]
},
"ACL": {
"isInherit": false,
"permission": [{
"permissionType": "U",
"userID": 10001,
"groupID": "",
"roleID": "",
"permissionString": "ROPKFIAENTCMDHZVWGLUSB",
"mustFlag": false
}]
}
}
}
--jmeter_is_great
Content-Type: text-plain
THIS IS TESTING FILE CONTENT
--jmeter_is_great--
[no cookies]
Request Headers:
Connection: keep-alive
Content-Length: 876
Content-Type: multipart/related; boundary=jmeter_is_great
响应数据
HTTP 状态 415 - 不支持的媒体类型
其实Document里面有一部分JSON如下:
"content": {
"binary": [80, 97, 114, 97, 68, 77, 32, 84, 69, 83, 84, 32, 102, 105, 108, 101]
}
我已尝试如下请求标头,然后将带有“内容”的整个 JSON 发送到 api:
[HTTP 标头] 授权:YXBpYWRtaW46cGFzc3dvcmQ= 内容类型:application/json
但是,也会抛出 HTTP 415 响应错误。
我读过一些有类似问题的文章: Testing REST API File Uploads in JMeter
期待任何见解!
【问题讨论】:
标签: jmeter multipart stress-testing