Important Update: Community URLs redirect issues are partially resolved. Learn More. .
2022-11-08 12:04 PM
I am attempting to obtain paged API data with a Javascript transporter. I currently get the data but it is only the first page. The java script gets the data through callback functions and I am having trouble knowing where to put a loop for the pages as I only get the page total when at the end of the callbacks.
I am trying to avoid using ?pagination=0 as the call could timeout.
2022-12-15 11:03 AM
I'm no JS dev, but I like to have some understanding of how the things I implement work. The November update of the User Profile & Contacts Sync uses a paged JS transporter. I suggest looking there.
function requestUsersPage(pageNumber, pageSize)
{
h.logInfo("requesting page " + pageNumber + " of users from Archer");
var postBody = createPostBody(createODataFilter(),pageNumber,pageSize);
// retrieve all the users from the Archer user store
aapi.restCall('/platformapi/core/system/user', 'POST', postBody, true, (err,result)=> {
if(err){
h.logError(err);
h.completeDataFeed(true);
}
else{
h.logInfo("HTTP - OK response received");
batchCount = result.length;
for(var i=0;i<result.length;i++)
{
if(result[i]['IsSuccessful']){
h.logInfo("retrieved user " + result[i]['RequestedObject']['UserName']);
users.push(result[i].RequestedObject);
}
}
if(batchCount == pageSize)
{
requestUsersPage(++pageNumber, pageSize)
}
else
{
populateContactInfo();
}
}
});
}