Web request pagination and iteration - HowTo

Alex Ziegltrum
Contributor
November 5, 2024

Hello 👋 I hope you can help me on. I am building an automation rule, that must get all members of a Jira group. The group can be more of 500 users. I learned, that using the API endpoint /rest/api/3/group/member uses pagination. My rule does the first web request and stores the account Ids in a variable, it does the second web request, where the start cursor was raised to 50 and adds the account Ids to the variable. I can't get the rule to do as many iterations, as the value "isLast" is true. My guess is, that the for-each configuration is not correct, but I don't have an idea, which value to put there. Here is the automation.

 

2024-11-05 21 10 23.png2024-11-05 21 16 36.png2024-11-05 21 17 08.png2024-11-05 21 17 31.png2024-11-05 21 17 08.png2024-11-05 21 18 07.png2024-11-05 21 19 48.png2024-11-05 21 20 09.png2024-11-05 21 20 28.png2024-11-05 21 21 16.png2024-11-05 21 21 30.png

And here is the audit log, my 2 markers indicate, that the first web request worked and the 2nd as well.

2024-11-05 21 23 47.png

Thanks to everyone spending their time to help 😊

Alex

4 answers

1 vote
Bill Sheboy
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.
November 6, 2024

Hi @Alex Ziegltrum 

Short answer: I recommend not trying this scenario with a Jira Automation rule.

 

First thing, I respectfully and strongly discourage having a rule that could potentially impact the group assignments for hundreds of Jira users.  There is too much risk of a simple mistake that may be difficult to undo...particularly because there is no way the audit log will show everything that changed for that many items.  Rules like this may also exceed the service limits for automation, possibly halting all rules in the site, from an hour up to an indefinite amount of time. (e.g., up to the end of the current month!)

With my disclaimers out of the way...

 

Next thing: automation branches which could be on more than one thing are executed in parallel and asynchronously.  There is no guarantee of when such branches will complete, up until the last step of the rule.

What that means for the rule you show is although the rule could repeatedly iterate through the pages of members (i.e., users) in the group, that will not occur in a predictable order.  And because the members could change while the rule is running, that will definitely lead to some potentially unpredictable behavior...including the rule failing as the page count could be different from the start to the end of the rule execution duration.

You do not show any logic for removing members from the group.  Perhaps consider how to determine if someone should be removed from the group, and then invert the logic so only they are examined / processed.

 

Finally, as @Marc - Devoteam described, that get members for group endpoint returns the isLast value after a call, but your rule checks a variable set from it before it is set, and so will be null.  And as described earlier, this branch is not a while-do loop, so the variable appears to not be relevant in this case.

 

Kind regards,
Bill

0 votes
Alex Ziegltrum
Contributor
November 6, 2024

Thank you, @Bill Sheboy and @Marc - Devoteam for taking the time, that's very appreciated.

And I see the point in your remarks. In the end and to my mind it shows at least two things. One - how powerful automation rules could be built basically and two - the lack of the Atlassian Group- and User-Management Dialogue.

Have a great day.

 

0 votes
Alex Ziegltrum
Contributor
November 6, 2024

@Bill Sheboy hope you don't mind the call :-) Is there a chance, that you could look over the automation?

0 votes
Marc - Devoteam
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.
November 5, 2024

Hi @Alex Ziegltrum 

What is the intention of getting this, is there a reason for this?

As this information is already available in the admin section of Jira.

Alex Ziegltrum
Contributor
November 6, 2024

Hi @Marc - Devoteam 

I need an automation, that frequently removes users of a gruop.

Marc - Devoteam
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.
November 6, 2024

Hi @Alex Ziegltrum 

I don't think getting a user list uses to the option "isLast" (indicates whether the page returned is the last one. Note that this property is not returned for all operations.)

I know when calling the endpoint to get user only the first 50 are pulled.

You would have to trigger the request multiple times and use the startAt parameter.

Suggest an answer

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

Atlassian Community Events