2017-04-12 183 views
0

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

请求正文:

{ “idEncargo”:XXXXXXXX }

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

有人知道这件事吗?

+0

“具体”请求是什么意思? – Ray

+0

嗨雷,我执行一个请求,我得到idEncargo的列表。后来,我需要为之前请求中的每个idEncargo执行另一个请求。 测试方案将是: 1 - 请求ListaEncargo - >列表IdEncargo(idEncargo1,idEncargo2,..,idEncargoN) 2. - 请求Encargo(idEncargo1) 3. - 请求Encargo(idEncargo2) .. 。 N + 1。 - 请求Encargo(idEncargoN) – Antonio

回答

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 

类似的东西可能工作...

希望帮助

亚历山大