This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Calendar Events in Canvas



Overview

The following operations allow you to work with calendar events. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with calendar events, see Sample configuration

OperationDescription

createCalendarEvent

Creates a calendar event.

getCalendarEventRetrieves a calendar event by ID.
listCalendarEventsRetrieves the calendar events of a user.

Operation details

This section provides further details on the operations related to calendar events.

Creating a calendar event

The createCalendarEvent operation creates a calendar event for a user.

createCalendarEvent
<canvas.createCalendarEvent>
    <childEventContextCode>{$ctx:childEventContextCode}</childEventContextCode>
    <title>{$ctx:title}</title>
    <childEventEndTimes>{$ctx:childEventEndTimes}</childEventEndTimes>
    <childEventStartTimes>{$ctx:childEventStartTimes}</childEventStartTimes>
    <description>{$ctx:description}</description>
    <contextCode>{$ctx:contextCode}</contextCode>
    <startAt>{$ctx:startAt}</startAt>
    <locationName>{$ctx:locationName}</locationName>
    <endAt>{$ctx:endAt}</endAt>
    <timeZoneEdited>{$ctx:timeZoneEdited}</timeZoneEdited>
	<locationAddress>{$ctx:locationAddress}</locationAddress>
</canvas.createCalendarEvent>
Properties
  • childEventContextCode: Context code(s) corresponding to the section-level start and end time(s).
  • title: The short title for the calendar event.
  • childEventEndTimes: The end date/time of the child event.
  • childEventStartTimes: The start date/time of the child event.
  • description: The longer description of the event.
  • contextCode: The context code of the course/group/user whose calendar this event should be added to.
  • startAt: The start date/time of the event.
  • locationName: The location name of the event.
  • endAt: The end date/time of the event.
  • timeZoneEdited: The time zone of the user editing the event.
  • locationAddress: The location address of the event.
Sample request

Following is a sample REST/JSON request that can be handled by the createCalendarEvent operation.

Sample Request for createCalendarEvent
{
	"apiUrl":"https://canvas.instructure.com",
	"accessToken":"7~UnsR6KCrYoap7KyAYMfNvANQeD59OinOIRp0S82FU7z1o5dz7o0VIBqNl6afoVBO",
	"childEventContextCode":"",
	"title":"Test Event",
	"childEventEndTimes":"",
	"childEventStartTimes":"",
	"description":"<b>It's that time again!</b>",
	"contextCode":"course_893239",
	"startAt":"2014-11-10T01:00:00Z",
	"locationName":"Virtusa World",
	"endAt":"2014-11-18T01:00:00Z",
	"timeZoneEdited":"",
	"locationAddress":"Collaboration,Virtusa World"
}
Related Canvas documentation

https://canvas.instructure.com/doc/api/calendar_events.html#method.calendar_events_api.create

Retrieving a calendar event

The getCalendarEvent operation retrieves a calendar event by ID.

getCalendarEvent
<canvas.getCalendarEvent>
	<calendarEventId>{$ctx:calendarEventId}</calendarEventId>
</canvas.getCalendarEvent>
Properties
  • calendarEventId: The ID of the calendar event to retrieve.
Sample request

Following is a sample REST/JSON request that can be handled by the getCalendarEvent operation.

getCalendarEvent
{
	"apiUrl":"https://canvas.instructure.com",
	"accessToken":"7~UnsR6KCrYoap7KyAYMfNvANQeD59OinOIRp0S82FU7z1o5dz7o0VIBqNl6afoVBO",
	"calendarEventId":"869358"
}
Related Canvas documentation

https://canvas.instructure.com/doc/api/calendar_events.html#method.calendar_events_api.show

Retrieving a list of calendar events

The listCalendarEvents operation retrieves a list of calendar events of a user.

listCalendarEvents
<canvas.listCalendarEvents>
    <startDate>{$ctx:startDate}</startDate>
    <undated>{$ctx:undated}</undated>
    <page>{$ctx:page}</page>
	<allEvents>{$ctx:allEvents}</allEvents>
    <endDate>{$ctx:endDate}</endDate>
    <perPage>{$ctx:perPage}</perPage>
    <type>{$ctx:type}</type>
	<contextCodes>{$ctx:contextCodes}</contextCodes>
</canvas.listCalendarEvents>
Properties
  • startDate: The event start date. Only returns events that occur on or after the start date. Defaults to "today".
  • undated: If "true", only returns undated events and ignores startDate and endDate.
  • page: The page number of results to retrieve.
  • allEvents: If "true", returns all events, ignoring startDate, endDate, and undated criteria.
  • endDate: The event end date. Only returns events that occur on or before the end date. Defaults to startDate.
  • perPage: The number of results to list per page.
  • type: The event type, either "event" or "assignment". Default is "event".
  • contextCodes: A comma-separated list of context codes of courses/groups/users whose events you want to see.
Sample request

Following is a sample REST/JSON request that can be handled by the listCalendarEvents operation.

listCalendarEvents
{
	"apiUrl":"https://canvas.instructure.com",
	"accessToken":"7~UnsR6KCrYoap7KyAYMfNvANQeD59OinOIRp0S82FU7z1o5dz7o0VIBqNl6afoVBO",
	"startDate":"",
	"undated":"",
	"allEvents":"true",
	"endDate":"",
	"type":"",
	"perPage":"4",
	"contextCodes":"course_893239 ,course_893240",
	"page":"1"
}
Related Canvas documentation

https://canvas.instructure.com/doc/api/calendar_events.html#method.calendar_events_api.index

Sample configuration

Following is a sample proxy service that illustrates how to connect to calendar events with the init operation and use the createCalendarEvent operation. The sample request for this proxy can be found in the createCalendarEvent sample request.

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
	<proxy xmlns="http://ws.apache.org/ns/synapse" name="canvas_createCalendarEvent" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
	 <target>
	 <inSequence onError="faultHandlerSeq">
      <property name="apiUrl" expression="json-eval($.apiUrl)"/>
      <property name="accessToken" expression="json-eval($.accessToken)"/>
      <property name="childEventContextCode" expression="json-eval($.childEventContextCode)"/>
      <property name="title" expression="json-eval($.title)"/>
      <property name="childEventEndTimes" expression="json-eval($.childEventEndTimes)"/>
      <property name="childEventStartTimes" expression="json-eval($.childEventStartTimes)"/>
      <property name="description" expression="json-eval($.description)"/>
      <property name="contextCode" expression="json-eval($.contextCode)"/>
      <property name="startAt" expression="json-eval($.startAt)"/>
      <property name="locationName" expression="json-eval($.locationName)"/>
      <property name="endAt" expression="json-eval($.endAt)"/>
      <property name="timeZoneEdited" expression="json-eval($.timeZoneEdited)"/>
      <property name="locationAddress" expression="json-eval($.locationAddress)"/>
      <canvas.init>
         <apiUrl>{$ctx:apiUrl}</apiUrl>
         <accessToken>{$ctx:accessToken}</accessToken>
      </canvas.init>
      <canvas.createCalendarEvent>
         <childEventContextCode>{$ctx:childEventContextCode}</childEventContextCode>
         <title>{$ctx:title}</title>
         <childEventEndTimes>{$ctx:childEventEndTimes}</childEventEndTimes>
         <childEventStartTimes>{$ctx:childEventStartTimes}</childEventStartTimes>
         <description>{$ctx:description}</description>
         <contextCode>{$ctx:contextCode}</contextCode>
         <startAt>{$ctx:startAt}</startAt>
         <locationName>{$ctx:locationName}</locationName>
         <endAt>{$ctx:endAt}</endAt>
         <timeZoneEdited>{$ctx:timeZoneEdited}</timeZoneEdited>
         <locationAddress>{$ctx:locationAddress}</locationAddress>
      </canvas.createCalendarEvent>
	   <respond/>
	 </inSequence>
	  <outSequence>
	   <send/>
	  </outSequence>
	 </target>
   <description/>
  </proxy>