Hi,
I was wondering is it possible to query api/collections/revisions/name_of_collection/_id to get node earlier versions?
There is field being updated and I would like to display all earlier versions.
Regards
Łukasz
Hi,
I was wondering is it possible to query api/collections/revisions/name_of_collection/_id to get node earlier versions?
There is field being updated and I would like to display all earlier versions.
Regards
Łukasz
There is no API route by default. But you could set one up.
Revisions are handled in the helper class “Revisions”
File: modules/Cockpit/Helper/Revisions.php
Access via: $this->app->helper('revisions')
The getList($uniqueEntryId, $limit, $skip)
method will return an array of revision entries matching your entry id.
So your setup for a custom endpoint for revisions could be:
# config/api/revisions.php
<?php
$entryId = $this->param('entryId', null);
$options = $this->param('options', []);
$limit = $options['limit']; // default is 50 in `getList`
$skip = $options['skip'];
if(!$entryId){
$this->stop(null, 400); // bad request
}
return $this->helper('revisions')->getList($entryId, $limit, $skip);
and it will be accessible with any valid account token like
/api/revisions?entryId=YOUR_ENTRY_ID&token=VALID_ACCOUNT_TOKEN
Note: not tested. but should work.