0

We are using self-hosted ActiveCollab v5.13.60 and I'm trying to generate a list of completed projects and tasks given a specific date. I've been toying with /whats-new/daily/ API request since it also gives a related object so I can pull in the project/task name easily.

From what I can tell the request only returns the last 50 items, if there are more than 50 items, then additional requests can be made with a ?page=X parameter.

Is there a way this request can return an un-paginated list, or all items for a given day?

Thanks!

S-T-H
  • 1

1 Answers1

1

Unfortunately not, you have to keep requesting the next page until there is nothing returned and then combine all of the results.

Within our in-house application, we have the following function (in PHP)

/**
 * Get pages of data with passed url
 * @param [string] $url The api endpoint
 * @return [array] All your data
 */
function getPagedData($url) {
    // Get all the projects in active collab
    $page = 1;
    $paged_records = array();
    $paged_records_results = $this->activeCollabClient->get($url . '?page=' . $page)->getJson();
    $paged_records = array_merge($paged_records, $paged_records_results);

    // Loop through pages
    while ($paged_records_results = $this->activeCollabClient->get($url . '?page=' . ++$page)->getJson()) {
        $paged_records = array_merge($paged_records, $paged_records_results);
    }
    return $paged_records;
}

It can then be called, passing the URL. In your case it could be used like:

getPagedData('whats-news/daily');

You will then get an array returned with all of the information contained.

mikestreety
  • 833
  • 6
  • 28