执行请求与邮递员n次

时间:2017-04-12 13:55:17

标签: json postman postman-collection-runner

我需要执行n次请求,在他的身体中有一个id值。集合运行器允许执行完整集合n次,但我没有找到任何具体请求。

请求正文:

{    “idEncargo”:XXXXXXXX }

从之前的请求中我得到一个包含几个idEncargo的数组。

有人知道吗?

1 个答案:

答案 0 :(得分:0)

在你的第一个请求中,如果你得到一个包含所有idEncargo的数组,你应该将它保存在一个全局变量中 然后在你的第二个请求中,你将遍历这个数组。

在您的第二个请求中,如果可能或者您想为每个idEncargo执行http请求,您可以尝试使用setNextRequest功能(请参阅http://blog.getpostman.com/2016/03/23/conditional-workflows-in-postman/) 喜欢做以下(抱歉,我是javascript的初学者,我只是建议算法):

request 1 - get my idEncargo array and set it in global // to bypass if array exists
        set global my_index = 0
        setNextRequest("request 2")
request 2 on idEncargo[my_index]
        in request 2 tests part do:
        my_index ++
        if my_index == max value
            setNextRequest("null") // breaks the loop
        else
            setNextRequest("request 2") // processes the next idEncargo

这样的东西可以起作用......

希望有所帮助

亚历山大

相关问题