"Get Scheduled Events" API seems to be broken - 1.8.0-alpha2

I scheduled a couple of events via the UI. Subsequently when I click on the “Schedule” link in the Xibo UI, I can see the schedules in the calendar. Also Chrome developer tools shows that the following call is made:

http://MyXiboServer/schedule/data/events?displayGroupIds[]=131&from=1451635200000&to=1454313600000&browser_timezone=America/Los_Angeles

and a response of

{
“success”: 1,
“result”: [
{
“id”: 25,
“title”: “mylayout scheduled on mydisplay”,
“url”: “/schedule/form/edit/25”,
“class”: “XiboFormButton event-important”,
“extra”: “priority”,
“start”: 1451719380000,
“end”: 1451726700000,
“event”: {
“eventId”: 25,
“eventTypeId”: 1,
“campaignId”: 21,
“commandId”: 0,
“displayGroups”: [
{
“displayGroupId”: 131,
“displayGroup”: “mydisplay”,
“description”: null,
“isDisplaySpecific”: “1”
}
],
“userId”: 1,
“fromDt”: “1451719380”,
“toDt”: “1451726700”,
“isPriority”: 1,
“displayOrder”: “1”,
“recurrenceType”: null,
“recurrenceDetail”: null,
“recurrenceRange”: null,
“campaign”: “mylayout”,
“command”: null
}
},

]
}

is returned. Everything looks good.

Now when I call the equivalent “Get Scheduled Events” API, I get a success but no results are returned:

curl -X GET -H “Authorization: token” -H ‘Accept: application/json’ -d ‘from=1251635200000&to=1454313600000’ “http://MyXiboServer/api/schedule/data/events

{
“success”: 1,
“result”:
}

What am I doing wrong here? Any help or pointers greatly appreciated.

Note: I noticed that I had to use a capital “D” for the “DisplayGroupIds” param. Using “displayGroupIds” gives an error.

It doesn’t look like you’re passing in any display group ids in your example curl request above? I’m taking a wild stab in the dark here but I would think you would need to pass in at least one group ID for the CMS to return anything meaningful.

Thanks for the tip. I retried with the displayGroupIds set as follows and still get back an empty object.

curl -X GET -H “Authorization: token” ‘http://MyXiboServer/api/schedule/data/events?displayGroupIds[]=145&from=1451635200000&to=1454313600000

I took a look at Schedule.php and noticed that the foreach loop in line#129 is never entered:

foreach (ScheduleFactory::query(‘schedule_detail.FromDT’, $filter) as $row) {

$filter dump is

array(4) { [“useDetail”]=> int(1)
[“fromDt”]=> int(1)
[“toDt”]=> int(1)
[“displayGroupIds”]=> array(1) { [0]=> int(145) }

The same (displayId, from and to combination) successfully returns the scheduled events when I click on the “Schedule” link in Xibo UI.

I think we’ve passed the point of my knowledge with this. @Dan will take a look when he’s able I’m sure.

I spent some time debugging this. First, I see a DEBUG entry in Xibo Log as follows:

Named route not found for name: schedule.edit.form#0 /home/user/xibo/vendor/slim/slim/Slim/Slim.php(1087): Slim\Router->urlFor(‘schedule.edit.f…’, Array) #1 /home/user/xibo/lib/Controller/Base.php(133): Slim\Slim->urlFor(‘schedule.edit.f…’, Array) #2 /home/user/xibo/lib/Controller/Schedule.php(156): Xibo\Controller\Base->urlFor(‘schedule.edit.f…’, Array) #3 [internal function]: Xibo\Controller\Schedule->eventData() #4 /home/user/xibo/vendor/slim/slim/Slim/Route.php(173): call_user_func_array(Array, Array) #5 [internal function]: Slim\Route->Slim{closure}() #6 /home/user/xibo/vendor/slim/slim/Slim/Route.php(468): call_user_func_array(Object(Closure), Array) #7 /home/user/xibo/vendor/slim/slim/Slim/Slim.php(1357): Slim\Route->dispatch() #8 /home/user/xibo/vendor/slim/slim/Slim/Middleware/Flash.php(85): Slim\Slim->call() #9 /home/user/xibo/vendor/slim/slim/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call() #10 /home/user/xibo/lib/Middleware/ApiAuthenticationOAuth.php(58): Slim\Middleware\MethodOverride->call() #11 /home/user/xibo/lib/Middleware/State.php(102): Xibo\Middleware\ApiAuthenticationOAuth->call() #12 /home/user/xibo/lib/Middleware/Storage.php(39): Xibo\Middleware\State->call() #13 /home/user/xibo/vendor/slim/slim/Slim/Slim.php(1302): Xibo\Middleware\Storage->call() #14 /home/user/xibo/web/api/index.php(95): Slim\Slim->run() #15 {main}

The offending line seems to be the one below (around line#150) in lib/Controller/Schedule.php :

$url = ($editable) ? $this->urlFor(‘schedule.edit.form’, [‘id’ => $row->eventId]) : ‘#’;

I forced $editable to be false as a temporary workaround and the API returns the scheduled events. The ‘url’ in the response is always “#” because of this. At this point I don’ care much about this.

I hope this information proves helpful to figure out the actual fix.

I think the format is incorrect. I believe it should be

FromDt=2015-11-01 14:40:00 ToDt=2015-11-13 08:13:08

I know the documentation says otherwise, but it doesn’t make sense to me that all the other date/time instances are in the fromDt and toDt format and this one uses microseconds in GET but then uses fromDt and toDt in PUT and POST

Thanks for the suggestion. The Swagger documentation says the dates should be entered as Timestamp values in microSeconds which seems to be what the API is honoring as well.
Entering in the more readable Date format, returns nothing. I see that the code is expecting a timestamp as well.
You are right that in all other API’s dates are expected to be in the format you mentioned.
I see this as a bug/ enhancement so that it is consistent across all API’s.

You are right, it does:

You are right again - the reason it is a time stamp is because of the Calendar Library we use in the Portal for generating the Schedule Page. That particular library requires microseconds… so the enhancement is either to:

  • Wrap the existing call in something else for the API
  • Fork the library and update it to use ISO dates