Hello team,
Looking for some input on how to process the result set from /beta/access-request-status?count=true:
The “X-Total-Count” resp. header returns 2070 access requests of which only the default/first 250 are returned.
Here’s a Java snippet I wrote that will paginate thru the entire result set and fetch the next set of records based on the offset:
public class Test {
public static void main(String[] args) {
int x = 2070; // value returned from initial API call
int resultOffset = 251;
int pageSize = 250;
int numOfPages;
int i = 0;
String apiUrl = "GET /beta/access-request-status?offset=";
if (x > pageSize) {
numOfPages = x / pageSize;
System.out.println("Num of pages: "+numOfPages);
while (resultOffset <= x) {
System.out.println("Iteration #"+ ++i);
System.out.println(apiUrl+resultOffset);
resultOffset+=pageSize+1;
}
}
}
}
Here’s the output:
Num of pages: 8
Iteration #1
GET /beta/access-request-status?offset=251
Iteration #2
GET /beta/access-request-status?offset=502
Iteration #3
GET /beta/access-request-status?offset=753
Iteration #4
GET /beta/access-request-status?offset=1004
Iteration #5
GET /beta/access-request-status?offset=1255
Iteration #6
GET /beta/access-request-status?offset=1506
Iteration #7
GET /beta/access-request-status?offset=1757
Iteration #8
GET /beta/access-request-status?offset=2008
Most of the GET API’s have this offset/count variable. Is this the right way to iterate through API’s that that only return a default (250) result set?