[英]How to import nested JSON data into Postman's collection runner?
I have the following 'nested JSON' data: 我有以下“嵌套JSON”数据:
[{
"method":"POST",
"endpoint":"/users",
"body":{
"username":"ZStGQoTVGvtBO",
"role":"DEVICE_ADMINISTRATOR"
},
"res_code":400,
"auth":[
"4565786",
"bncfgnjfgnjgt"
]
}]
How to import it into Postman collection runner? 如何将其导入Postman CollectionRunner? I am able to import simple JSON data but not nested JSON.
我可以导入简单的JSON数据,但不能导入嵌套的JSON。 And also there seems to be a problem in importing the "auth" element sometimes it's ignoring the "auth" element, sometimes it's just importing the second value of "auth" only.
而且在导入“ auth”元素时似乎也存在问题,有时它忽略了“ auth”元素,有时只是仅导入了“ auth”的第二个值。
You can do it manually in pre-request script: 您可以在请求前脚本中手动进行操作:
pm.variables.set("username", data.body.username);//<- acess to nested value, you can't use {{body.username}}
or if you want to input some part of your data to request body you can: 或者,如果您想输入部分数据以请求正文,则可以:
pm.variables.set("bodyPart", JSON.stringify(data.someobject))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.