是否有标头管理器配置来解决使用Json主体的JMeter中的422错误?

时间:2019-04-09 01:58:44

标签: json jmeter http-headers

我在Jmeter HTTP请求中的Json正文数据是:

{"someone":[],"customer":[{"firstName":"John","lastName":"Smith","email":"Someone1@gmail.com","mainClient":true,"document":"1234567","documentType":3,"phone":"+12344567876"}],"hotelId":${hotelId},"hotelRoomTypes":[{"total":1,"hotelRoomTypeId":"${hotelRoomTypes}"}]}

我在响应中收到消息:

{"code":422,"message":"api.error.product.Something.available"}

1 个答案:

答案 0 :(得分:1)

您的JSON请求格式无效。检查图像:

enter image description here

我已经尝试了一个样本测试来检查在JSON格式有效时它是否有效。添加了CSV数据集配置元素,虚拟采样器,并查看了结果树侦听器以进行检查。效果很好。

在JSON请求中将${hotelId}更改为"${hotelId}",然后重试。

CSV文件包含123456作为hotelId,并使用变量调用将其传递到Dummy sampler请求。并在View Results tree侦听器中找到了预期的结果。

Dummy Sampler

View Results Tree

希望这会起作用。