how to use jira automation to iterate over a external api which returns 50 results at at a time

Pravin July 19, 2024

Hi,

I am trying to hit a third part API, to get the usernames and store these information into Jira Insights.

The third party API, returns only 50 results at a time (pagination).

How can I use Jira automation to incrementally go voer this API and get the results. For e.g.

When the jira automation runs for the first time, it gets 50 usersname, and stores in JIra insights, then it runs again but this time hits the api, and page 2 to get the 51-100 usernames and so on

 

Please suggest.

1 answer

3 votes
Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 19, 2024

@Pravin -

Since it is dealing with a third party API calls, you need to contact the vendor of the APIs for suggestion and support.  The behavior of the APIs returning the results is not controlled within JSM, thus automation rule has no ways to change the returning results pagination process.

Sorry.

Best, Joseph Chung Yin

Pravin July 19, 2024

I did contact them and as per them that is how it is, 50 results per call...

Like John Funk likes this
Jim Knepley - ReleaseTEAM
Atlassian Partner
July 19, 2024

Who is the 3rd party?

Like John Funk likes this
Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 19, 2024

@Pravin -

Unfortunately, it is not possible to use automation rule to obtain all of your results from the the third party APIs.  

However, if in their APIs, you can specify the result set (i.e. something like 2nd 50 results, 3rd 50 results) being returned, then you may be able to conduct multiple Webrequest actions in the rule, obtain the results then update a local variable for the rule with the result set.  Once you obtained all results and they are in the local variable, you should be able to use the local variable content for your Jira Insight updates...

Hope this makes sense.

Best, Joseph

Like John Funk likes this
Pravin July 19, 2024

they do have the option in there API endpoint:

&page=1&size=50

So is it possible to iterate this API with increasing the page number by 1 on each run until all results are received? 

Like John Funk likes this
Jim Knepley - ReleaseTEAM
Atlassian Partner
July 19, 2024

Incrementing the page parameter is almost certainly the intention of the author.

I don't have a strong opinion around changing the page size, but making the page size larger can sometimes be faster overall since you send fewer requests.

Like John Funk likes this
Pravin July 20, 2024

Do you have example/screenshot of the rule on how this looks like?

Suggest an answer

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

Atlassian Community Events