我正在使用JMeter,我目前正面临这个问题。
我想对API函数执行POST请求,但不知何故,当它被发送到调用时,我的正文数据不会以JSON格式发送。
这是发送的正文数据
{
"project_id": "2",
"name": "Jaya Jadon",
"phone": "0123456789",
"email": "email@email.com",
"remarks": "",
"co_applicants":[
{
"name": "Wongg Feig Uncle",
"phone": "0123476798",
"email": "unclee@weie.com"
},
{
"name": "Wineg Feie Father",
"phone": "0123496897",
"email": "fatheer@weie.com"
}
],
"documents": [
{
"booking_form": "",
"consent_form": [
"https://www.jjj.com/CF1.jpg"
],
"ic_passport_no":[
"https://www.jjj.com/IC1.jpg"
],
"additional": ""
}
]
}
但这是发送POST请求时发送的内容
{
"{\r\n\t\"project_id\"" => ">\"2\",\r\n\t\"name\"=>\"Jaya Jadon\",\r\n\t\"phone\"=>\"0123456789\",\r\n\t\"email\": \"email@email.com\",\r\n\t\"remarks\": \"\",\r\n\t\"co_applicants\":[\r\n\t\t{\r\n\t\t\t\"name\": \"Wongg Feig Uncle\",\r\n\t\t\t\"phone\": \"0123476798\",\r\n\t\t\t\"email\": \"unclee@weie.com\"\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"name\": \"Wineg Feie Father\",\r\n\t\t\t\"phone\": \"0123496897\",\r\n\t\t\t\"email\": \"fatheer@weie.com\"\r\n\t\t}\r\n\t],\r\n\t\"documents\": [\r\n\t\t{\r\n\t\t\t\"booking_form\": \"\",\r\n\t\t\t\"consent_form\": [\t\r\n\t\t\t\t\"https://www.jjj.com/CF1.jpg\"\r\n\t\t\t],\r\n\t\t\t\"ic_passport_no\":[\r\n\t\t\t\t\"https://www.jjj.com/IC1.jpg\"\r\n\t\t\t],\r\n\t\t\t\"additional\": \"\"\r\n\t\t}\r\n\t]\r\n}",
"format" => "json",
"controller" => "v1/lp_developer_referrals",
"action" => "create"
}
这就是我期待的结果
{
"project_id" => "2",
"name" => "Jaya Jadon",
"phone" => "0123456789",
"email" => "email@email.com",
"remarks" => nil,
"co_applicants" => nil,
"documents" => [
[0] {
"booking_form" => nil,
"consent_form" => [
[0] "https://www.jjj.com/CF1.jpg"
],
"ic_passport_no" => [
[0] "https://www.jjj.com/IC1.jpg"
],
"additional" => nil
}
],
"format" => "json",
"controller" => "v1/lp_developer_referrals",
"action" => "create"
}
有人可以向我解释为什么我的Jmeter没有将我的身体数据作为json对象吗?
答案 0 :(得分:1)
JMeter应按原样发送数据"",仔细检查以下配置:
Use multipart/form-data for HTTP POST
框未选中
Content-Type
header发送值application/json
答案 1 :(得分:0)
请尝试添加" HTTP标头管理器"使用" Content-Type"值" application / json"在您提出要求之前或在其中。告诉我们行为是否正确。