Automation - Loop through components based on Web Request response

Luca Schernbeck
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 16, 2024

Hi,

 

I have built an automation that sends data from the Jira issue to an external database via a PUT request.
This is using a response ID that is saved in the Jira issue as well as the external database. I have noticed that when the Jira issue is created and the automation starts, the database has not yet created the value with that response ID and thus causing a 404 for the PUT request.
I therefore wanted to see if I can either:

1. Create an artificial delay before the PUT request to allow enough time for the database to catch up and create the response ID. From my testing, it seems that a delay of 1-3 minutes should be sufficient. I couldn't find a way to create such an artificial delay.

2. Create a loop in my automation that uses a GET request to check whether the response ID was created. In the attached image you can see what I am trying to do. If the {{webResponse.status}} = 200 the PUT request should execute. If {{webResponse.status}} = 404 it should loop back to the GET request to check if the response was created in the meantime. Preferably I would like to still include an artificial delay if possible as I suspect the GET request will return 404s for abut 1-3 minutes.

Audit log - Automation - Product Expert - Jira 2024-04-16 at 1.55.59 p.m..jpg

4 answers

1 vote
Radu Dumitriu _Appfire_ April 16, 2024

Try Power Scripts. You can achieve 1 and / or 2 easily, and, BTW, you can integrate that DB natively (although make sure you secure it via TLS certificates, which we provide as mechanism).

 

0 votes
Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 16, 2024

Hello @Luca Schernbeck 

Welcome.

You need to insert a "Refetch Issue" action after the Trigger part to retrieve any fields being saved in Jira's SOR.

That said, I am not clear what is the flow here with the first GET statement.

Does the first GET depend on Response ID being available in both Jira and external DB? If so, does external DB always have this resposnse ID or are you updating it as part of a different rule?

Finally, there is no "wait" option. You just need to break up your rule in 2. Once you see 404, you then call this other rule and send all data in payload... This new rule you need to create will have trigger = Incoming webhook, where, once you receive the payload from rule 1, you do the same steps such as GET from your end point, check if its 200 etc, and if its not 200, you recursively call the same rule ...you do this until you see 200 or certain attempts have happened.

But yeah, without knowing full details, i will start with inserting a refetch after your trigger statement and go from there.

0 votes
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 16, 2024

Hi @Luca Schernbeck , your #1 is not possible. You would need to handle the delay outside of the rule, e.g. initiate a new delayed web request into a new rule from the first rule. The other option would be to somehow 'flag' the issue in this rule and then have another rule scheduled to run every x-minutes looking for issues with the flag.

0 votes
C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 16, 2024

Do you have an external system where you could create a simple REST API that would return success after a delay? Then you could call that, have the rule wait until it returns, and then continue with the PUT to the database. That would be simple to create if you have an external system where you can run it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events