【发布时间】:2022-05-10 08:53:37
【问题描述】:
如何根据数组中端点响应中出现的值在 Postman 中添加自动环境变量?
在下面的示例中,我想使用“id3”值并将其保存为动态变量。
{
"test": 123,
"test2": [],
"test3": [
{
"id": 0,
"id2": 4554336,
"id3": 30,
"id4": 0
}
]
}
我认为它会很简单:
let jsonData = pm.response.json();
pm.environment.set("test_name", jsonData.test3.id);
但是这个设置是用空值保存变量。
【问题讨论】: