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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Top Solution Authors
Top Kudoed Authors
Users online (46,566)