Monday, April 27, 2009

Creating an agent to create an iCalendar entry

I have a problem where I want to create an agent in a db that generates an iCalendar feed that I can then add to my (and other’s) federated calendar in 8.5. The database which will host the agent is currently in 6.5 – which shouldn’t and hopefully doesn’t make a difference. Anyway, to test this out I created a quick dummy agent:

Sub Initialize
    Print "Content-type: text/calendar" & Chr(13) & Chr(10)
    Print ""
    Print "BEGIN:VCALENDAR"
    Print "VERSION:2.0"
    Print "PRODID:-//DTF//Projects//EN"
    Print "BEGIN:VEVENT"
    Print "UID:20090427T150000Z-12345@blah.blah.au"
    Print "SEQUENCE:0"
    Print "DTSTART:20090427T150000"
    Print "DTEND:20090427T160000"
    Print "SUMMARY:Nigel Test"
    Print "DESCRIPTION:This is the description"
    Print "TRANSP:TRANSPARENT"
    Print "END:VEVENT"
    Print "END:VCALENDAR"
End Sub

Pretty dull really.

Now, when I hit this agent with a browser, it asks me if I want to open or save – when I save it, then import it in an 8.5 client everything works wonderfully. It creates the entry in the calendar with the right fields etc.

But, if instead I try to add the agent as a calendar FEED to my client I keep getting the error:

net.fortuna.ical4j.Data.ParserException: Error at line 1: Expected [BEGIN], read [<html>]

Now, that would make sense if the agent wasn't rewriting the mime type to text/calendar, but I have checked the HTTP Header (using the browser) and it's right.

Any ideas?

I’ll be sure to let you know if I figure it out