Generate context inside a while loop in an automation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generate context inside a while loop in an automation

L4 Transporter

An Api call is created in an automation program. The call to the API needs to wait for a value to set to "FINISHED", so a while loop is created waiting for this value. However, I'd like to know the current status of this value setting the value in context.

Why is not setting this value on the context?

 

status=""

While status != "FINISHED":

status=doHttpRequest()

demisto.setContext("status", status)

1 accepted solution

Accepted Solutions

Did not test it inside a while loop.

The recommended way to do it is to return a scheduled command and not through a while loop.
https://xsoar.pan.dev/docs/integrations/scheduled-commands

Also, calling an API from an automation is  kind of an anti-pattern(although it is possible). Usually, the automation will call an integration command that calls the API. 

View solution in original post

4 REPLIES 4

L2 Linker

arnarayanan_0-1658743481388.png

demisto.setContext("status", "test")

Something like the above worked for me

inside a while loop?

Did not test it inside a while loop.

The recommended way to do it is to return a scheduled command and not through a while loop.
https://xsoar.pan.dev/docs/integrations/scheduled-commands

Also, calling an API from an automation is  kind of an anti-pattern(although it is possible). Usually, the automation will call an integration command that calls the API. 

Interesting, I'll study how to implement

  • 1 accepted solution
  • 2583 Views
  • 4 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!