skip navigation
Trumba Web Calendar Software
Trumba Help Center What’s New | FAQ | Support Forum | Email Support

Programmatically upload iCal files

The iCalendar (a.k.a. .ics) import allows events to be created, updated, or deleted on a Trumba calendar by sending an iCalendar (RFC 2445) format file to the Trumba server through an HTTP PUT operation. This allows existing events in Trumba to be modified with the data in the iCal file but without altering other event data or duplicating events. 

The service requires authentication using HTTP BASIC authentication. Because the password is sent via clear text, it is recommended (but not required) that the service be accessed via a secure https connection. The feed only supports a single VCALENDAR component per HTTP PUT operation which means that iCalendar CANCEL methods must be sent in separate HTTP PUT operations.

Topic Links

URL Format

The URL shown below represents the base URL that should be used to perform the HTTP PUT operation.  The “<ID>” portion of the URL must be replaced with the numeric calendar ID of the destination calendar within Trumba.

URL: http://www.trumba.com/service/calendar.<ID>.ics

Example URL for calendar ID=123456: http://www.trumba.com/service/calendar.123456.ics

Example URL for calendar with webname Foobar: https://www.trumba.com/service/Foobar.ics

The URL can also include the following query string parameters.

Parameter

Description

Allowed

Values

Default

Value

delta

The delta parameter controls whether the incoming feed is considered to be a full feed of data or only changes. 

·         When the value is false, the system imports the events in the feed and deletes any events that exist in Trumba but do not exist in the feed. 

·         When the value is true, the system will only delete events if an explicit CANCEL method is specified in the iCalendar file.

true,false

false

Response Values

The response to the HTTP PUT operation contains an XML structure with a root “Response” node and one or more “ResponseMessage” nodes providing information and validation feedback.  The following messages may be returned.   Response messages may include the UID of the related event and a line number in the feed file where appropriate.

Response Codes and Descriptions

Code

Description

Level

1101

Event added

Information

1102

Event deleted

Information

1103

Event modified

Information

2101

Property not recognized

Warning

2102

Content line is invalid

Warning

2103

DateTime is invalid

Warning

2104

UTC offset is invalid

Warning

2105

Duration is invalid

Warning

3101

ICS file must contain a single VCALENDAR

Error

Examples

This section provides a simple code snippet that performs an http put of a .ics file.  For brevity, it intentionally does not use error handling logic that would be present in most programs.

Note …The ics import and related topics assume that you are familiar with programming languages, the http protocol, and how URL parameters work, and that you can easily find your way around HTML or other web programming-language code.

This code will not work unmodified.  Various parameters (in CAPS in this example), such as authentication information and the path to the .ics file must be updated to reflect your account and published calendar name. 

byte[] request; // request content as byte array
using (StreamReader sr = new StreamReader(@"YOUR_ICS_FILE.ics")) { request = new ASCIIEncoding().GetBytes(sr.ReadToEnd()); }
string UriStr = "https://www.trumba.com/service/YOUR_CALENDAR_WEBNAME.ics?delta=true";
CredentialCache MyCredentialCache = new CredentialCache(); 
NetworkCredential creds = new NetworkCredential("TRUMBA_ACCOUNT_EMAIL_ADDR", "TRUMBA_ACCOUNT_PASSOWRD", "");
MyCredentialCache.Add(new Uri(UriStr), "Basic", creds);
HttpWebRequest Request = (HttpWebRequest) HttpWebRequest.Create(UriStr);
Request.Credentials = MyCredentialCache;
Request.Method = "PUT";
Request.ContentLength = request.Length; Stream requestStream = Request.GetRequestStream();
requestStream.Write(request, 0, request.Length); // file sizes > 2048 bytes may need chunking
requestStream.Close();
WebResponse Response = Request.GetResponse();
Stream ResponseStream = Response.GetResponseStream();
StreamReader responseReader = new StreamReader(ResponseStream);
string responseString = responseReader.ReadToEnd();
Console.Write(responseString);
ResponseStream.Close();
Response.Close(); 
 

The resultant xml response stream, output to the console in the above example, might look like this:

<?xml version="1.0"?>

<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <ResponseMessage Code="1101" Description="Event added" Level="Information" UID="D70C88D5-E5A1-48EC-84A4-D05DBD5CD8F6-99" />

</Response>

 

Privacy | Terms | Public Calendars