将值保存在 collection 级别而不是邮递员的环境级别

Saving values in collection level and not in environment level in postman

我是邮递员的新手,我有大约 200 个服务需要自动化。现在,对于每项服务,我都需要保存一些值并在其他服务中检索。现在我可以通过保存和从环境变量中检索来做到这一点吗?

除了保存在环境变量中还有其他选择吗?就像在 collection 级别本身一样?如果我开始在其中保存值,环境列表看起来也很大?

寻找不同的选择?

你可以define collection variables

Click ellipsis (...) next to the collection name, and select “Edit” to open the EDIT COLLECTION modal. Select the Variables tab to add and edit collection variables

使用代码:

pm.collectionVariables.set("variable_key", "variable_value");
pm.collectionVariables.get("variable_key");