Postman 在邮递员中使用pm.request.body.raw时显示NaN错误

Postman 在邮递员中使用pm.request.body.raw时显示NaN错误,postman,Postman,我在请求正文中传递以下参数: { "locale": "en", "type": "abc", "model": { "id": "123" } } console.log(JSON.parse(pm.request.body.raw).locale) console.log(JSON.parse(pm.request.body.raw).type) console.log(JSON.parse(pm.request.body.raw).m

我在请求正文中传递以下参数:

{   
    "locale": "en",
    "type": "abc",
    "model": {
        "id": "123"
    }
}
console.log(JSON.parse(pm.request.body.raw).locale)
console.log(JSON.parse(pm.request.body.raw).type)
console.log(JSON.parse(pm.request.body.raw).model)
console.log(JSON.parse(pm.request.body.raw).model.id)
原始JSON格式

我试图使用
requestBody=JSON.parse(pm.request.body.raw)在测试选项卡中检索相同的参数
但是当我将输出写入控制台时,我会得到一个
NaN


如何检索正文请求中发送到测试脚本中的参数?

您可以在
测试
选项卡中使用它来记录该请求正文中的任何值:

{   
    "locale": "en",
    "type": "abc",
    "model": {
        "id": "123"
    }
}
console.log(JSON.parse(pm.request.body.raw).locale)
console.log(JSON.parse(pm.request.body.raw).type)
console.log(JSON.parse(pm.request.body.raw).model)
console.log(JSON.parse(pm.request.body.raw).model.id)

您希望如何使用“测试”选项卡中的数据?只需将其记录到控制台?