cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
slong
Frequent Visitor

GETting and storing JSON results over multiple REST API calls

So I have a REST API (Jira in this case) and I'm retrieving quite a large number of records. The API only allows a maximum of 100 records to be retrieved at any one time.

 

The API does return the total amount of records on the first call. So let's say I had 284 records to retrieve and store in a Collection. At the moment I am doing it in a very hacky way like this and ending up with all records in a collection called jiraRawData, but there more be a more robust way to deal with any amount of records.

 

What's the best way to do this seeing as PowerApps doesn't have a proper loop construct ? Thanks.

ClearCollect(
    jiraRawData1,
    JIRACloudAPI.GetIssuesForJQLQuery(
        {
            jql: "project = MYPROJECT AND issuetype in (standardIssueTypes(), subTaskIssueTypes(), Bug, Epic, Feedback, Spike, Story, Task, Bug-Subtask, Sub-task) AND fixVersion in (10.14.0, 11.0.0, 11.1.0) ORDER BY created DESC",
            startAt: 0,
            maxResults: 100
        }
    ).issues
);
ClearCollect(
    jiraRawData2,
    jiraRawData1,
    JIRACloudAPI.GetIssuesForJQLQuery(
        {
            jql: "project = MYPROJECT AND issuetype in (standardIssueTypes(), subTaskIssueTypes(), Bug, Epic, Feedback, Spike, Story, Task, Bug-Subtask, Sub-task) AND fixVersion in (10.14.0, 11.0.0, 11.1.0) ORDER BY created DESC",
            startAt: 100,
            maxResults: 100
        }
    ).issues
);
ClearCollect(
    jiraRawData,
    jiraRawData2,
    JIRACloudAPI.GetIssuesForJQLQuery(
        {
            jql: "project = MYPROJECT AND issuetype in (standardIssueTypes(), subTaskIssueTypes(), Bug, Epic, Feedback, Spike, Story, Task, Bug-Subtask, Sub-task) AND fixVersion in (10.14.0, 11.0.0, 11.1.0) ORDER BY created DESC",
            startAt: 200,
            maxResults: 100
        }
    ).issues
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @slong ,

 

According to your description, I think the forall() function and the collect() function can meet your needs.

 

I did a test for you.

 

1\ I assume you have 284 records to retrieve.

So you need to loop 3 times.

 

2\ You could try the following formula:

ClearCollect(Thevar,0); ForAll(Sequence(3),Collect(jiraRawData,

ClearCollect(jiraRawData1,JIRACloudAPI.GetIssuesForJQLQuery({jql: "project = MYPROJECT AND issuetype in (standardIssueTypes(), subTaskIssueTypes(), Bug, Epic, Feedback, Spike, Story, Task, Bug-Subtask, Sub-task) AND fixVersion in (10.14.0, 11.0.0, 11.1.0) ORDER BY created DESC",startAt: Last(Thevar).Value,maxResults: 100}).issues)) ; Collect(Thevar,Last(Thevar).Value+100)

)

 

Best Regards,

Wearsky

If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

1 REPLY 1
v-xiaochen-msft
Community Support
Community Support

Hi @slong ,

 

According to your description, I think the forall() function and the collect() function can meet your needs.

 

I did a test for you.

 

1\ I assume you have 284 records to retrieve.

So you need to loop 3 times.

 

2\ You could try the following formula:

ClearCollect(Thevar,0); ForAll(Sequence(3),Collect(jiraRawData,

ClearCollect(jiraRawData1,JIRACloudAPI.GetIssuesForJQLQuery({jql: "project = MYPROJECT AND issuetype in (standardIssueTypes(), subTaskIssueTypes(), Bug, Epic, Feedback, Spike, Story, Task, Bug-Subtask, Sub-task) AND fixVersion in (10.14.0, 11.0.0, 11.1.0) ORDER BY created DESC",startAt: Last(Thevar).Value,maxResults: 100}).issues)) ; Collect(Thevar,Last(Thevar).Value+100)

)

 

Best Regards,

Wearsky

If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,445)