I am trying to pull the events from my calendar or calendars through the element api but I am running into an issue with the element type. I found an older post that gave examples but they no longer function correctly. When I try to fetch the data I get this error {"error":{"code":404,"message":"Endpoint has an invalid elementType"}}.

I tried all the examples given in the link and as many other permutations as I could think of to fix the element type but to no avail. Here is the code I have right now:

use Solspace\Calendar\Calendar;

return [
    'endpoints' => [
        'api/events.json' => function() {
            return [
                'elementType' => Entry::class,
                'transformer' => function(Calendar_EventModel $event) {
                  $exceptions = [];
                  foreach($event->exceptions as $exception) {
                    $exceptions[] = $exception->date;

                  return [
                    'id' => $event->id,
                    'title' => $event->title,
                    'calendarId' => $event->calendarId,
                    'slug' => $event->slug,
                    'startDate' => $event->startDate,
                    'endDate' => $event->endDate,

Any suggestions would be greatly appreciated. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.