12 Dec 2023 02:45 PM - last edited on 13 Dec 2023 09:44 AM by MaciejNeumann
Hi all 😀
Do you know any way to create a loop in a monitor ?
I need to make some HTTP requests, based on a previous body response.
I already use the skip function (https://docs.dynatrace.com/docs/shortlink/http-monitor-pre-post-script#skip-http-requests) but I didn't see a previous/goto function.
Thanks in advance !
12 Dec 2023 03:54 PM
Hi,
Depending on what information you need in next action, maybe, you can check pass variables.
Something as make HTTP request, save answer value in a variable and make other request with that variable.
Best regards
12 Dec 2023 04:08 PM
Hi @AntonPineiro,
I already use a lot of pass variables, but that's not a solution for my usecase.
Maybe I'm not clear enough.
I need to execute the same request or go back to a previous HTTP request in the same HTTP monitor.
On Postman, the function exists when you use postman.setNextRequest("xxxx"), you can go to a previous request in the same collection.
Tell me if you need more details 😉
12 Dec 2023 05:51 PM - edited 12 Dec 2023 05:51 PM
Hi,
I had never heard about it. I would say trying it using pure JavaScript with JavaScript clickpath event.
I hope someone can suggest you a better solution.
Best regards
12 Dec 2023 06:15 PM
@JeanBlanc synthetic tests do not allow loops as far as I know, probably purely for sanity reasons so the test will not stay in loop and never finish.
You can only skip some steps either in HTTP or in Browser monitors. In other words, you are limited by the number of iterations. You can just do two equal HTTP requests, and in the first one use the skip function to skip the second one if desired. If not the flow will continue to the second request.
13 Dec 2023 04:46 PM
Thank you @Julius_Loman
Unfortunately, in my case I have between 5 and 50 HTTP requests needed.
So it will be difficult to manually build each step and skip useless ones.
13 Dec 2023 08:30 PM
Not really, I'd use a scripted approach and create / update the synthetic test programmatically using API so you don't have to create it manually. Maybe it's wise to rethink if it's really necessary to do it this way - but I don't know your case.