首页 > 解决方案 > 在 Postman 集合中,其中一项服务只需要调用一次

问题描述

我正在设计一个相当简单的集合,集合中有两个服务:

我已经设法从服务 #1 中获取令牌并将其设置为变量,并在请求 #2 中使用所述令牌。然后,我在 Runner 中使用 csv 文件使用不同的参数调用服务 #2。

我想要实现的是只运行一次服务#1,而不是运行与 CSV 上的行数一样多的次数。可能吗?

标签: postmanpostman-collection-runnerpostman-pre-request-script

解决方案


You can use postman.setNextRequest("request #2"); in the Tests script of request #2 to skip the execution of request #1 after the first run.

But you also need to add a condition to only do that while pm.info.iteration is smaller than your amount of required executions to avoid an endless loop.


推荐阅读